diff --git a/CHANGELOG.md b/CHANGELOG.md index d737add665..459e51e285 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Enhancements: - Two new generic method overloads `proxyGenerator.CreateClassProxy([options], constructorArguments, interceptors)` (@backstromjoel, #636) - Allow specifying which attributes should always be copied to proxy class by adding attribute type to `AttributesToAlwaysReplicate`. Previously only non-inherited, with `Inherited=false`, attributes were copied. (@shoaibshakeel381, #633) - Support for C# 8+ [default interface methods](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-8.0/default-interface-methods) in interface and class proxies without target (@stakx, #661) +- DynamicProxy's public API has been augmented with nullable reference type annotations (@stakx, #668) Bugfixes: - `ArgumentException`: "Could not find method overriding method" with overridden class method having generic by-ref parameter (@stakx, #657) diff --git a/ref/Castle.Core-net462.cs b/ref/Castle.Core-net462.cs index e811e9fd7f..a463161bc5 100644 --- a/ref/Castle.Core-net462.cs +++ b/ref/Castle.Core-net462.cs @@ -2446,23 +2446,24 @@ namespace Castle.DynamicProxy public abstract class AbstractInvocation : Castle.DynamicProxy.IInvocation { protected readonly object proxyObject; - protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public object[] Arguments { get; } - public System.Type[] GenericArguments { get; } - public abstract object InvocationTarget { get; } + protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public object?[] Arguments { get; } + public System.Type[]? GenericArguments { get; } + public abstract object? InvocationTarget { get; } public System.Reflection.MethodInfo Method { get; } - public abstract System.Reflection.MethodInfo MethodInvocationTarget { get; } + public abstract System.Reflection.MethodInfo? MethodInvocationTarget { get; } public object Proxy { get; } - public object ReturnValue { get; set; } - public abstract System.Type TargetType { get; } + public object? ReturnValue { get; set; } + public abstract System.Type? TargetType { get; } public Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo() { } - public object GetArgumentValue(int index) { } + public object? GetArgumentValue(int index) { } public System.Reflection.MethodInfo GetConcreteMethod() { } - public System.Reflection.MethodInfo GetConcreteMethodInvocationTarget() { } + public System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget() { } protected abstract void InvokeMethodOnTarget(); public void Proceed() { } - public void SetArgumentValue(int index, object value) { } + public void SetArgumentValue(int index, object? value) { } public void SetGenericMethodArguments(System.Type[] arguments) { } + [System.Diagnostics.CodeAnalysis.DoesNotReturn] protected void ThrowOnNoTarget() { } } [System.Serializable] @@ -2470,7 +2471,7 @@ public class AllMethodsHook : Castle.DynamicProxy.IProxyGenerationHook { protected static readonly System.Collections.Generic.ICollection SkippedTypes; public AllMethodsHook() { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public virtual void MethodsInspected() { } public virtual void NonProxyableMemberNotification(System.Type type, System.Reflection.MemberInfo memberInfo) { } @@ -2478,12 +2479,12 @@ public virtual bool ShouldInterceptMethod(System.Type type, System.Reflection.Me } public class CustomAttributeInfo : System.IEquatable { - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public bool Equals(Castle.DynamicProxy.CustomAttributeInfo other) { } - public override bool Equals(object obj) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public bool Equals(Castle.DynamicProxy.CustomAttributeInfo? other) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public static Castle.DynamicProxy.CustomAttributeInfo FromExpression(System.Linq.Expressions.Expression> expression) { } } @@ -2493,19 +2494,19 @@ public DefaultProxyBuilder() { } public DefaultProxyBuilder(Castle.DynamicProxy.ModuleScope scope) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.ModuleScope ModuleScope { get; } - public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } [System.Serializable] public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { - void ChangeInvocationTarget(object target); + void ChangeInvocationTarget(object? target); [System.Obsolete("Use ((IProxyTargetAccessor)invocation.Proxy).DynProxySetTarget(target) instead.")] - void ChangeProxyTarget(object target); + void ChangeProxyTarget(object? target); } public interface IInterceptor { @@ -2513,24 +2514,24 @@ public interface IInterceptor } public interface IInterceptorSelector { - Castle.DynamicProxy.IInterceptor[] SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); + Castle.DynamicProxy.IInterceptor[]? SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); } public interface IInvocation { - object[] Arguments { get; } - System.Type[] GenericArguments { get; } - object InvocationTarget { get; } + object?[] Arguments { get; } + System.Type[]? GenericArguments { get; } + object? InvocationTarget { get; } System.Reflection.MethodInfo Method { get; } - System.Reflection.MethodInfo MethodInvocationTarget { get; } + System.Reflection.MethodInfo? MethodInvocationTarget { get; } object Proxy { get; } - object ReturnValue { get; set; } - System.Type TargetType { get; } + object? ReturnValue { get; set; } + System.Type? TargetType { get; } Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo(); - object GetArgumentValue(int index); + object? GetArgumentValue(int index); System.Reflection.MethodInfo GetConcreteMethod(); - System.Reflection.MethodInfo GetConcreteMethodInvocationTarget(); + System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget(); void Proceed(); - void SetArgumentValue(int index, object value); + void SetArgumentValue(int index, object? value); } public interface IInvocationProceedInfo { @@ -2540,11 +2541,11 @@ public interface IProxyBuilder { Castle.Core.Logging.ILogger Logger { get; set; } Castle.DynamicProxy.ModuleScope ModuleScope { get; } - System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); } public interface IProxyGenerationHook { @@ -2559,51 +2560,51 @@ public interface IProxyGenerator Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class; TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) @@ -2613,19 +2614,19 @@ TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.Pro } public interface IProxyTargetAccessor { - object DynProxyGetTarget(); - void DynProxySetTarget(object target); + object? DynProxyGetTarget(); + void DynProxySetTarget(object? target); Castle.DynamicProxy.IInterceptor[] GetInterceptors(); } public class MixinData { - public MixinData(System.Collections.Generic.IEnumerable mixinInstances) { } + public MixinData(System.Collections.Generic.IEnumerable? mixinInstances) { } public System.Collections.Generic.IEnumerable MixinInterfaces { get; } - public System.Collections.Generic.IEnumerable Mixins { get; } + public System.Collections.Generic.IEnumerable Mixins { get; } public bool ContainsMixin(System.Type mixinInterfaceType) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } - public object GetMixinInstance(System.Type mixinInterfaceType) { } + public object? GetMixinInstance(System.Type mixinInterfaceType) { } public int GetMixinPosition(System.Type mixinInterfaceType) { } } public class ModuleScope @@ -2636,19 +2637,19 @@ public ModuleScope() { } public ModuleScope(bool savePhysicalAssembly) { } public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule) { } public ModuleScope(bool savePhysicalAssembly, bool disableSignedModule, string strongAssemblyName, string strongModulePath, string weakAssemblyName, string weakModulePath) { } - public string StrongNamedModuleDirectory { get; } + public string? StrongNamedModuleDirectory { get; } public string StrongNamedModuleName { get; } - public string WeakNamedModuleDirectory { get; } + public string? WeakNamedModuleDirectory { get; } public string WeakNamedModuleName { get; } public void LoadAssemblyIntoCache(System.Reflection.Assembly assembly) { } - public string SaveAssembly() { } - public string SaveAssembly(bool strongNamed) { } + public string? SaveAssembly() { } + public string? SaveAssembly(bool strongNamed) { } public static byte[] GetKeyPair() { } } public class PersistentProxyBuilder : Castle.DynamicProxy.DefaultProxyBuilder { public PersistentProxyBuilder() { } - public string SaveAssembly() { } + public string? SaveAssembly() { } } [System.Serializable] public class ProxyGenerationOptions : System.Runtime.Serialization.ISerializable @@ -2661,11 +2662,11 @@ public ProxyGenerationOptions(Castle.DynamicProxy.IProxyGenerationHook hook) { } public bool HasMixins { get; } public Castle.DynamicProxy.IProxyGenerationHook Hook { get; set; } public Castle.DynamicProxy.MixinData MixinData { get; } - public Castle.DynamicProxy.IInterceptorSelector Selector { get; set; } + public Castle.DynamicProxy.IInterceptorSelector? Selector { get; set; } public void AddDelegateMixin(System.Delegate @delegate) { } public void AddDelegateTypeMixin(System.Type delegateType) { } public void AddMixinInstance(object instance) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } public void Initialize() { } @@ -2679,81 +2680,81 @@ public ProxyGenerator(Castle.DynamicProxy.IProxyBuilder builder) { } public ProxyGenerator(bool disableSignedModule) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } - protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } - protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object? target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } protected void CheckNotGenericTypeDefinition(System.Type type, string argumentName) { } - protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable types, string argumentName) { } + protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable? types, string argumentName) { } public object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object[] constructorArguments) { } - protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object?[]? constructorArguments) { } + protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - protected System.Collections.Generic.List GetConstructorArguments(object target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Collections.Generic.List GetConstructorArguments(object? target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } } public static class ProxyUtil { public static System.Delegate CreateDelegateToMixin(object proxy, System.Type delegateType) { } public static TDelegate CreateDelegateToMixin(object proxy) { } - public static object GetUnproxiedInstance(object instance) { } + public static object? GetUnproxiedInstance(object instance) { } public static System.Type GetUnproxiedType(object instance) { } public static bool IsAccessible(System.Reflection.MethodBase method) { } public static bool IsAccessible(System.Type type) { } - public static bool IsAccessible(System.Reflection.MethodBase method, out string message) { } - public static bool IsProxy(object instance) { } + public static bool IsAccessible(System.Reflection.MethodBase method, [System.Diagnostics.CodeAnalysis.NotNullWhen(false)] out string? message) { } + public static bool IsProxy(object? instance) { } public static bool IsProxyType(System.Type type) { } } [System.Serializable] @@ -2785,17 +2786,17 @@ namespace Castle.DynamicProxy.Internal { public abstract class CompositionInvocation : Castle.DynamicProxy.AbstractInvocation { - protected object target; - protected CompositionInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + protected object? target; + protected CompositionInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected void EnsureValidProxyTarget(object newTarget) { } protected void EnsureValidTarget() { } } public abstract class InheritanceInvocation : Castle.DynamicProxy.AbstractInvocation { - protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } + protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } public override object InvocationTarget { get; } public override System.Reflection.MethodInfo MethodInvocationTarget { get; } public override System.Type TargetType { get; } @@ -2810,16 +2811,16 @@ protected override void InvokeMethodOnTarget() { } [System.Serializable] public sealed class InterfaceMethodWithoutTargetInvocation : Castle.DynamicProxy.AbstractInvocation { - public InterfaceMethodWithoutTargetInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + public InterfaceMethodWithoutTargetInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected override void InvokeMethodOnTarget() { } } public static class TypeUtil { public static System.Type[] GetAllInterfaces(this System.Type type) { } - public static System.Type GetTypeOrNull(object target) { } + public static System.Type? GetTypeOrNull(object? target) { } public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { } } } diff --git a/ref/Castle.Core-net6.0.cs b/ref/Castle.Core-net6.0.cs index 38e7bed03c..dd8a8652a4 100644 --- a/ref/Castle.Core-net6.0.cs +++ b/ref/Castle.Core-net6.0.cs @@ -2415,30 +2415,31 @@ namespace Castle.DynamicProxy public abstract class AbstractInvocation : Castle.DynamicProxy.IInvocation { protected readonly object proxyObject; - protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public object[] Arguments { get; } - public System.Type[] GenericArguments { get; } - public abstract object InvocationTarget { get; } + protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public object?[] Arguments { get; } + public System.Type[]? GenericArguments { get; } + public abstract object? InvocationTarget { get; } public System.Reflection.MethodInfo Method { get; } - public abstract System.Reflection.MethodInfo MethodInvocationTarget { get; } + public abstract System.Reflection.MethodInfo? MethodInvocationTarget { get; } public object Proxy { get; } - public object ReturnValue { get; set; } - public abstract System.Type TargetType { get; } + public object? ReturnValue { get; set; } + public abstract System.Type? TargetType { get; } public Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo() { } - public object GetArgumentValue(int index) { } + public object? GetArgumentValue(int index) { } public System.Reflection.MethodInfo GetConcreteMethod() { } - public System.Reflection.MethodInfo GetConcreteMethodInvocationTarget() { } + public System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget() { } protected abstract void InvokeMethodOnTarget(); public void Proceed() { } - public void SetArgumentValue(int index, object value) { } + public void SetArgumentValue(int index, object? value) { } public void SetGenericMethodArguments(System.Type[] arguments) { } + [System.Diagnostics.CodeAnalysis.DoesNotReturn] protected void ThrowOnNoTarget() { } } public class AllMethodsHook : Castle.DynamicProxy.IProxyGenerationHook { protected static readonly System.Collections.Generic.ICollection SkippedTypes; public AllMethodsHook() { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public virtual void MethodsInspected() { } public virtual void NonProxyableMemberNotification(System.Type type, System.Reflection.MemberInfo memberInfo) { } @@ -2446,12 +2447,12 @@ public virtual bool ShouldInterceptMethod(System.Type type, System.Reflection.Me } public class CustomAttributeInfo : System.IEquatable { - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public bool Equals(Castle.DynamicProxy.CustomAttributeInfo other) { } - public override bool Equals(object obj) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public bool Equals(Castle.DynamicProxy.CustomAttributeInfo? other) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public static Castle.DynamicProxy.CustomAttributeInfo FromExpression(System.Linq.Expressions.Expression> expression) { } } @@ -2461,19 +2462,19 @@ public DefaultProxyBuilder() { } public DefaultProxyBuilder(Castle.DynamicProxy.ModuleScope scope) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.ModuleScope ModuleScope { get; } - public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } [System.Serializable] public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { - void ChangeInvocationTarget(object target); + void ChangeInvocationTarget(object? target); [System.Obsolete("Use ((IProxyTargetAccessor)invocation.Proxy).DynProxySetTarget(target) instead.")] - void ChangeProxyTarget(object target); + void ChangeProxyTarget(object? target); } public interface IInterceptor { @@ -2481,24 +2482,24 @@ public interface IInterceptor } public interface IInterceptorSelector { - Castle.DynamicProxy.IInterceptor[] SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); + Castle.DynamicProxy.IInterceptor[]? SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); } public interface IInvocation { - object[] Arguments { get; } - System.Type[] GenericArguments { get; } - object InvocationTarget { get; } + object?[] Arguments { get; } + System.Type[]? GenericArguments { get; } + object? InvocationTarget { get; } System.Reflection.MethodInfo Method { get; } - System.Reflection.MethodInfo MethodInvocationTarget { get; } + System.Reflection.MethodInfo? MethodInvocationTarget { get; } object Proxy { get; } - object ReturnValue { get; set; } - System.Type TargetType { get; } + object? ReturnValue { get; set; } + System.Type? TargetType { get; } Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo(); - object GetArgumentValue(int index); + object? GetArgumentValue(int index); System.Reflection.MethodInfo GetConcreteMethod(); - System.Reflection.MethodInfo GetConcreteMethodInvocationTarget(); + System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget(); void Proceed(); - void SetArgumentValue(int index, object value); + void SetArgumentValue(int index, object? value); } public interface IInvocationProceedInfo { @@ -2508,11 +2509,11 @@ public interface IProxyBuilder { Castle.Core.Logging.ILogger Logger { get; set; } Castle.DynamicProxy.ModuleScope ModuleScope { get; } - System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); } public interface IProxyGenerationHook { @@ -2527,51 +2528,51 @@ public interface IProxyGenerator Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class; TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) @@ -2581,19 +2582,19 @@ TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.Pro } public interface IProxyTargetAccessor { - object DynProxyGetTarget(); - void DynProxySetTarget(object target); + object? DynProxyGetTarget(); + void DynProxySetTarget(object? target); Castle.DynamicProxy.IInterceptor[] GetInterceptors(); } public class MixinData { - public MixinData(System.Collections.Generic.IEnumerable mixinInstances) { } + public MixinData(System.Collections.Generic.IEnumerable? mixinInstances) { } public System.Collections.Generic.IEnumerable MixinInterfaces { get; } - public System.Collections.Generic.IEnumerable Mixins { get; } + public System.Collections.Generic.IEnumerable Mixins { get; } public bool ContainsMixin(System.Type mixinInterfaceType) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } - public object GetMixinInstance(System.Type mixinInterfaceType) { } + public object? GetMixinInstance(System.Type mixinInterfaceType) { } public int GetMixinPosition(System.Type mixinInterfaceType) { } } public class ModuleScope @@ -2618,12 +2619,13 @@ public ProxyGenerationOptions(Castle.DynamicProxy.IProxyGenerationHook hook) { } public bool HasMixins { get; } public Castle.DynamicProxy.IProxyGenerationHook Hook { get; set; } public Castle.DynamicProxy.MixinData MixinData { get; } - public Castle.DynamicProxy.IInterceptorSelector Selector { get; set; } + public Castle.DynamicProxy.IInterceptorSelector? Selector { get; set; } public void AddDelegateMixin(System.Delegate @delegate) { } public void AddDelegateTypeMixin(System.Type delegateType) { } public void AddMixinInstance(object instance) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } + [System.Diagnostics.CodeAnalysis.MemberNotNull("mixinData")] public void Initialize() { } public object[] MixinsAsArray() { } } @@ -2635,81 +2637,81 @@ public ProxyGenerator(Castle.DynamicProxy.IProxyBuilder builder) { } public ProxyGenerator(bool disableSignedModule) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } - protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } - protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object? target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } protected void CheckNotGenericTypeDefinition(System.Type type, string argumentName) { } - protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable types, string argumentName) { } + protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable? types, string argumentName) { } public object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object[] constructorArguments) { } - protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object?[]? constructorArguments) { } + protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - protected System.Collections.Generic.List GetConstructorArguments(object target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Collections.Generic.List GetConstructorArguments(object? target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } } public static class ProxyUtil { public static System.Delegate CreateDelegateToMixin(object proxy, System.Type delegateType) { } public static TDelegate CreateDelegateToMixin(object proxy) { } - public static object GetUnproxiedInstance(object instance) { } + public static object? GetUnproxiedInstance(object instance) { } public static System.Type GetUnproxiedType(object instance) { } public static bool IsAccessible(System.Reflection.MethodBase method) { } public static bool IsAccessible(System.Type type) { } - public static bool IsAccessible(System.Reflection.MethodBase method, out string message) { } - public static bool IsProxy(object instance) { } + public static bool IsAccessible(System.Reflection.MethodBase method, [System.Diagnostics.CodeAnalysis.NotNullWhen(false)] out string? message) { } + public static bool IsProxy(object? instance) { } public static bool IsProxyType(System.Type type) { } } public class StandardInterceptor : Castle.DynamicProxy.IInterceptor @@ -2740,17 +2742,17 @@ namespace Castle.DynamicProxy.Internal { public abstract class CompositionInvocation : Castle.DynamicProxy.AbstractInvocation { - protected object target; - protected CompositionInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + protected object? target; + protected CompositionInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected void EnsureValidProxyTarget(object newTarget) { } protected void EnsureValidTarget() { } } public abstract class InheritanceInvocation : Castle.DynamicProxy.AbstractInvocation { - protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } + protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } public override object InvocationTarget { get; } public override System.Reflection.MethodInfo MethodInvocationTarget { get; } public override System.Type TargetType { get; } @@ -2763,16 +2765,16 @@ protected override void InvokeMethodOnTarget() { } } public sealed class InterfaceMethodWithoutTargetInvocation : Castle.DynamicProxy.AbstractInvocation { - public InterfaceMethodWithoutTargetInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + public InterfaceMethodWithoutTargetInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected override void InvokeMethodOnTarget() { } } public static class TypeUtil { public static System.Type[] GetAllInterfaces(this System.Type type) { } - public static System.Type GetTypeOrNull(object target) { } + public static System.Type? GetTypeOrNull(object? target) { } public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { } } } \ No newline at end of file diff --git a/ref/Castle.Core-netstandard2.0.cs b/ref/Castle.Core-netstandard2.0.cs index 9e8efdf470..53928d09b0 100644 --- a/ref/Castle.Core-netstandard2.0.cs +++ b/ref/Castle.Core-netstandard2.0.cs @@ -2413,30 +2413,31 @@ namespace Castle.DynamicProxy public abstract class AbstractInvocation : Castle.DynamicProxy.IInvocation { protected readonly object proxyObject; - protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public object[] Arguments { get; } - public System.Type[] GenericArguments { get; } - public abstract object InvocationTarget { get; } + protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public object?[] Arguments { get; } + public System.Type[]? GenericArguments { get; } + public abstract object? InvocationTarget { get; } public System.Reflection.MethodInfo Method { get; } - public abstract System.Reflection.MethodInfo MethodInvocationTarget { get; } + public abstract System.Reflection.MethodInfo? MethodInvocationTarget { get; } public object Proxy { get; } - public object ReturnValue { get; set; } - public abstract System.Type TargetType { get; } + public object? ReturnValue { get; set; } + public abstract System.Type? TargetType { get; } public Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo() { } - public object GetArgumentValue(int index) { } + public object? GetArgumentValue(int index) { } public System.Reflection.MethodInfo GetConcreteMethod() { } - public System.Reflection.MethodInfo GetConcreteMethodInvocationTarget() { } + public System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget() { } protected abstract void InvokeMethodOnTarget(); public void Proceed() { } - public void SetArgumentValue(int index, object value) { } + public void SetArgumentValue(int index, object? value) { } public void SetGenericMethodArguments(System.Type[] arguments) { } + [System.Diagnostics.CodeAnalysis.DoesNotReturn] protected void ThrowOnNoTarget() { } } public class AllMethodsHook : Castle.DynamicProxy.IProxyGenerationHook { protected static readonly System.Collections.Generic.ICollection SkippedTypes; public AllMethodsHook() { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public virtual void MethodsInspected() { } public virtual void NonProxyableMemberNotification(System.Type type, System.Reflection.MemberInfo memberInfo) { } @@ -2444,12 +2445,12 @@ public virtual bool ShouldInterceptMethod(System.Type type, System.Reflection.Me } public class CustomAttributeInfo : System.IEquatable { - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public bool Equals(Castle.DynamicProxy.CustomAttributeInfo other) { } - public override bool Equals(object obj) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public bool Equals(Castle.DynamicProxy.CustomAttributeInfo? other) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public static Castle.DynamicProxy.CustomAttributeInfo FromExpression(System.Linq.Expressions.Expression> expression) { } } @@ -2459,19 +2460,19 @@ public DefaultProxyBuilder() { } public DefaultProxyBuilder(Castle.DynamicProxy.ModuleScope scope) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.ModuleScope ModuleScope { get; } - public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } [System.Serializable] public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { - void ChangeInvocationTarget(object target); + void ChangeInvocationTarget(object? target); [System.Obsolete("Use ((IProxyTargetAccessor)invocation.Proxy).DynProxySetTarget(target) instead.")] - void ChangeProxyTarget(object target); + void ChangeProxyTarget(object? target); } public interface IInterceptor { @@ -2479,24 +2480,24 @@ public interface IInterceptor } public interface IInterceptorSelector { - Castle.DynamicProxy.IInterceptor[] SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); + Castle.DynamicProxy.IInterceptor[]? SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); } public interface IInvocation { - object[] Arguments { get; } - System.Type[] GenericArguments { get; } - object InvocationTarget { get; } + object?[] Arguments { get; } + System.Type[]? GenericArguments { get; } + object? InvocationTarget { get; } System.Reflection.MethodInfo Method { get; } - System.Reflection.MethodInfo MethodInvocationTarget { get; } + System.Reflection.MethodInfo? MethodInvocationTarget { get; } object Proxy { get; } - object ReturnValue { get; set; } - System.Type TargetType { get; } + object? ReturnValue { get; set; } + System.Type? TargetType { get; } Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo(); - object GetArgumentValue(int index); + object? GetArgumentValue(int index); System.Reflection.MethodInfo GetConcreteMethod(); - System.Reflection.MethodInfo GetConcreteMethodInvocationTarget(); + System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget(); void Proceed(); - void SetArgumentValue(int index, object value); + void SetArgumentValue(int index, object? value); } public interface IInvocationProceedInfo { @@ -2506,11 +2507,11 @@ public interface IProxyBuilder { Castle.Core.Logging.ILogger Logger { get; set; } Castle.DynamicProxy.ModuleScope ModuleScope { get; } - System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); } public interface IProxyGenerationHook { @@ -2525,51 +2526,51 @@ public interface IProxyGenerator Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class; TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) @@ -2579,19 +2580,19 @@ TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.Pro } public interface IProxyTargetAccessor { - object DynProxyGetTarget(); - void DynProxySetTarget(object target); + object? DynProxyGetTarget(); + void DynProxySetTarget(object? target); Castle.DynamicProxy.IInterceptor[] GetInterceptors(); } public class MixinData { - public MixinData(System.Collections.Generic.IEnumerable mixinInstances) { } + public MixinData(System.Collections.Generic.IEnumerable? mixinInstances) { } public System.Collections.Generic.IEnumerable MixinInterfaces { get; } - public System.Collections.Generic.IEnumerable Mixins { get; } + public System.Collections.Generic.IEnumerable Mixins { get; } public bool ContainsMixin(System.Type mixinInterfaceType) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } - public object GetMixinInstance(System.Type mixinInterfaceType) { } + public object? GetMixinInstance(System.Type mixinInterfaceType) { } public int GetMixinPosition(System.Type mixinInterfaceType) { } } public class ModuleScope @@ -2616,11 +2617,11 @@ public ProxyGenerationOptions(Castle.DynamicProxy.IProxyGenerationHook hook) { } public bool HasMixins { get; } public Castle.DynamicProxy.IProxyGenerationHook Hook { get; set; } public Castle.DynamicProxy.MixinData MixinData { get; } - public Castle.DynamicProxy.IInterceptorSelector Selector { get; set; } + public Castle.DynamicProxy.IInterceptorSelector? Selector { get; set; } public void AddDelegateMixin(System.Delegate @delegate) { } public void AddDelegateTypeMixin(System.Type delegateType) { } public void AddMixinInstance(object instance) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public void Initialize() { } public object[] MixinsAsArray() { } @@ -2633,81 +2634,81 @@ public ProxyGenerator(Castle.DynamicProxy.IProxyBuilder builder) { } public ProxyGenerator(bool disableSignedModule) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } - protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } - protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object? target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } protected void CheckNotGenericTypeDefinition(System.Type type, string argumentName) { } - protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable types, string argumentName) { } + protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable? types, string argumentName) { } public object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object[] constructorArguments) { } - protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object?[]? constructorArguments) { } + protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - protected System.Collections.Generic.List GetConstructorArguments(object target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Collections.Generic.List GetConstructorArguments(object? target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } } public static class ProxyUtil { public static System.Delegate CreateDelegateToMixin(object proxy, System.Type delegateType) { } public static TDelegate CreateDelegateToMixin(object proxy) { } - public static object GetUnproxiedInstance(object instance) { } + public static object? GetUnproxiedInstance(object instance) { } public static System.Type GetUnproxiedType(object instance) { } public static bool IsAccessible(System.Reflection.MethodBase method) { } public static bool IsAccessible(System.Type type) { } - public static bool IsAccessible(System.Reflection.MethodBase method, out string message) { } - public static bool IsProxy(object instance) { } + public static bool IsAccessible(System.Reflection.MethodBase method, [System.Diagnostics.CodeAnalysis.NotNullWhen(false)] out string? message) { } + public static bool IsProxy(object? instance) { } public static bool IsProxyType(System.Type type) { } } public class StandardInterceptor : Castle.DynamicProxy.IInterceptor @@ -2738,17 +2739,17 @@ namespace Castle.DynamicProxy.Internal { public abstract class CompositionInvocation : Castle.DynamicProxy.AbstractInvocation { - protected object target; - protected CompositionInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + protected object? target; + protected CompositionInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected void EnsureValidProxyTarget(object newTarget) { } protected void EnsureValidTarget() { } } public abstract class InheritanceInvocation : Castle.DynamicProxy.AbstractInvocation { - protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } + protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } public override object InvocationTarget { get; } public override System.Reflection.MethodInfo MethodInvocationTarget { get; } public override System.Type TargetType { get; } @@ -2761,16 +2762,16 @@ protected override void InvokeMethodOnTarget() { } } public sealed class InterfaceMethodWithoutTargetInvocation : Castle.DynamicProxy.AbstractInvocation { - public InterfaceMethodWithoutTargetInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + public InterfaceMethodWithoutTargetInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected override void InvokeMethodOnTarget() { } } public static class TypeUtil { public static System.Type[] GetAllInterfaces(this System.Type type) { } - public static System.Type GetTypeOrNull(object target) { } + public static System.Type? GetTypeOrNull(object? target) { } public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { } } } \ No newline at end of file diff --git a/ref/Castle.Core-netstandard2.1.cs b/ref/Castle.Core-netstandard2.1.cs index 1a81b5e911..40b01b56be 100644 --- a/ref/Castle.Core-netstandard2.1.cs +++ b/ref/Castle.Core-netstandard2.1.cs @@ -2413,30 +2413,31 @@ namespace Castle.DynamicProxy public abstract class AbstractInvocation : Castle.DynamicProxy.IInvocation { protected readonly object proxyObject; - protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public object[] Arguments { get; } - public System.Type[] GenericArguments { get; } - public abstract object InvocationTarget { get; } + protected AbstractInvocation(object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public object?[] Arguments { get; } + public System.Type[]? GenericArguments { get; } + public abstract object? InvocationTarget { get; } public System.Reflection.MethodInfo Method { get; } - public abstract System.Reflection.MethodInfo MethodInvocationTarget { get; } + public abstract System.Reflection.MethodInfo? MethodInvocationTarget { get; } public object Proxy { get; } - public object ReturnValue { get; set; } - public abstract System.Type TargetType { get; } + public object? ReturnValue { get; set; } + public abstract System.Type? TargetType { get; } public Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo() { } - public object GetArgumentValue(int index) { } + public object? GetArgumentValue(int index) { } public System.Reflection.MethodInfo GetConcreteMethod() { } - public System.Reflection.MethodInfo GetConcreteMethodInvocationTarget() { } + public System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget() { } protected abstract void InvokeMethodOnTarget(); public void Proceed() { } - public void SetArgumentValue(int index, object value) { } + public void SetArgumentValue(int index, object? value) { } public void SetGenericMethodArguments(System.Type[] arguments) { } + [System.Diagnostics.CodeAnalysis.DoesNotReturn] protected void ThrowOnNoTarget() { } } public class AllMethodsHook : Castle.DynamicProxy.IProxyGenerationHook { protected static readonly System.Collections.Generic.ICollection SkippedTypes; public AllMethodsHook() { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public virtual void MethodsInspected() { } public virtual void NonProxyableMemberNotification(System.Type type, System.Reflection.MemberInfo memberInfo) { } @@ -2444,12 +2445,12 @@ public virtual bool ShouldInterceptMethod(System.Type type, System.Reflection.Me } public class CustomAttributeInfo : System.IEquatable { - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues) { } - public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object[] propertyValues, System.Reflection.FieldInfo[] namedFields, object[] fieldValues) { } - public bool Equals(Castle.DynamicProxy.CustomAttributeInfo other) { } - public override bool Equals(object obj) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues) { } + public CustomAttributeInfo(System.Reflection.ConstructorInfo constructor, object?[] constructorArgs, System.Reflection.PropertyInfo[] namedProperties, object?[] propertyValues, System.Reflection.FieldInfo[] namedFields, object?[] fieldValues) { } + public bool Equals(Castle.DynamicProxy.CustomAttributeInfo? other) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public static Castle.DynamicProxy.CustomAttributeInfo FromExpression(System.Linq.Expressions.Expression> expression) { } } @@ -2459,19 +2460,19 @@ public DefaultProxyBuilder() { } public DefaultProxyBuilder(Castle.DynamicProxy.ModuleScope scope) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.ModuleScope ModuleScope { get; } - public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } } [System.Serializable] public sealed class DynamicProxyException : System.Exception { } public interface IChangeProxyTarget { - void ChangeInvocationTarget(object target); + void ChangeInvocationTarget(object? target); [System.Obsolete("Use ((IProxyTargetAccessor)invocation.Proxy).DynProxySetTarget(target) instead.")] - void ChangeProxyTarget(object target); + void ChangeProxyTarget(object? target); } public interface IInterceptor { @@ -2479,24 +2480,24 @@ public interface IInterceptor } public interface IInterceptorSelector { - Castle.DynamicProxy.IInterceptor[] SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); + Castle.DynamicProxy.IInterceptor[]? SelectInterceptors(System.Type type, System.Reflection.MethodInfo method, Castle.DynamicProxy.IInterceptor[] interceptors); } public interface IInvocation { - object[] Arguments { get; } - System.Type[] GenericArguments { get; } - object InvocationTarget { get; } + object?[] Arguments { get; } + System.Type[]? GenericArguments { get; } + object? InvocationTarget { get; } System.Reflection.MethodInfo Method { get; } - System.Reflection.MethodInfo MethodInvocationTarget { get; } + System.Reflection.MethodInfo? MethodInvocationTarget { get; } object Proxy { get; } - object ReturnValue { get; set; } - System.Type TargetType { get; } + object? ReturnValue { get; set; } + System.Type? TargetType { get; } Castle.DynamicProxy.IInvocationProceedInfo CaptureProceedInfo(); - object GetArgumentValue(int index); + object? GetArgumentValue(int index); System.Reflection.MethodInfo GetConcreteMethod(); - System.Reflection.MethodInfo GetConcreteMethodInvocationTarget(); + System.Reflection.MethodInfo? GetConcreteMethodInvocationTarget(); void Proceed(); - void SetArgumentValue(int index, object value); + void SetArgumentValue(int index, object? value); } public interface IInvocationProceedInfo { @@ -2506,11 +2507,11 @@ public interface IProxyBuilder { Castle.Core.Logging.ILogger Logger { get; set; } Castle.DynamicProxy.ModuleScope ModuleScope { get; } - System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); - System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); + System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options); } public interface IProxyGenerationHook { @@ -2525,51 +2526,51 @@ public interface IProxyGenerator Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); - TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors); + TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; - TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class; object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class; object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); - object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors); + object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors); TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class; TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) @@ -2579,19 +2580,19 @@ TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.Pro } public interface IProxyTargetAccessor { - object DynProxyGetTarget(); - void DynProxySetTarget(object target); + object? DynProxyGetTarget(); + void DynProxySetTarget(object? target); Castle.DynamicProxy.IInterceptor[] GetInterceptors(); } public class MixinData { - public MixinData(System.Collections.Generic.IEnumerable mixinInstances) { } + public MixinData(System.Collections.Generic.IEnumerable? mixinInstances) { } public System.Collections.Generic.IEnumerable MixinInterfaces { get; } - public System.Collections.Generic.IEnumerable Mixins { get; } + public System.Collections.Generic.IEnumerable Mixins { get; } public bool ContainsMixin(System.Type mixinInterfaceType) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } - public object GetMixinInstance(System.Type mixinInterfaceType) { } + public object? GetMixinInstance(System.Type mixinInterfaceType) { } public int GetMixinPosition(System.Type mixinInterfaceType) { } } public class ModuleScope @@ -2616,11 +2617,11 @@ public ProxyGenerationOptions(Castle.DynamicProxy.IProxyGenerationHook hook) { } public bool HasMixins { get; } public Castle.DynamicProxy.IProxyGenerationHook Hook { get; set; } public Castle.DynamicProxy.MixinData MixinData { get; } - public Castle.DynamicProxy.IInterceptorSelector Selector { get; set; } + public Castle.DynamicProxy.IInterceptorSelector? Selector { get; set; } public void AddDelegateMixin(System.Delegate @delegate) { } public void AddDelegateTypeMixin(System.Type delegateType) { } public void AddMixinInstance(object instance) { } - public override bool Equals(object obj) { } + public override bool Equals(object? obj) { } public override int GetHashCode() { } public void Initialize() { } public object[] MixinsAsArray() { } @@ -2633,81 +2634,81 @@ public ProxyGenerator(Castle.DynamicProxy.IProxyBuilder builder) { } public ProxyGenerator(bool disableSignedModule) { } public Castle.Core.Logging.ILogger Logger { get; set; } public Castle.DynamicProxy.IProxyBuilder ProxyBuilder { get; } - protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } - protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } + protected System.Collections.Generic.List BuildArgumentListForClassProxyWithTarget(object? target, Castle.DynamicProxy.ProxyGenerationOptions options, Castle.DynamicProxy.IInterceptor[] interceptors) { } protected void CheckNotGenericTypeDefinition(System.Type type, string argumentName) { } - protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable types, string argumentName) { } + protected void CheckNotGenericTypeDefinitions(System.Collections.Generic.IEnumerable? types, string argumentName) { } public object CreateClassProxy(System.Type classToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxy(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxy(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TClass CreateClassProxy(params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxy(Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object[] constructorArguments) { } - protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, object[] constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TClass CreateClassProxyWithTarget(TClass target, params Castle.DynamicProxy.IInterceptor[] interceptors) + protected object CreateClassProxyInstance(System.Type proxyType, System.Collections.Generic.List proxyArguments, System.Type classToProxy, object?[]? constructorArguments) { } + protected System.Type CreateClassProxyType(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateClassProxyTypeWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateClassProxyWithTarget(System.Type classToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateClassProxyWithTarget(System.Type classToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, object?[]? constructorArguments, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TClass CreateClassProxyWithTarget(TClass? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - public TClass CreateClassProxyWithTarget(TClass target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TClass CreateClassProxyWithTarget(TClass? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TClass : class { } - protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } - protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, System.Type targetType, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Type CreateInterfaceProxyTypeWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithTarget(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, object target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, params Castle.DynamicProxy.IInterceptor[] interceptors) + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithTargetInterface(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, object? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.IInterceptor interceptor) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } - public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[] additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, params Castle.DynamicProxy.IInterceptor[] interceptors) { } + public virtual object CreateInterfaceProxyWithoutTarget(System.Type interfaceToProxy, System.Type[]? additionalInterfacesToProxy, Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.IInterceptor interceptor) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } public TInterface CreateInterfaceProxyWithoutTarget(Castle.DynamicProxy.ProxyGenerationOptions options, params Castle.DynamicProxy.IInterceptor[] interceptors) where TInterface : class { } - protected System.Collections.Generic.List GetConstructorArguments(object target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } + protected System.Collections.Generic.List GetConstructorArguments(object? target, Castle.DynamicProxy.IInterceptor[] interceptors, Castle.DynamicProxy.ProxyGenerationOptions options) { } } public static class ProxyUtil { public static System.Delegate CreateDelegateToMixin(object proxy, System.Type delegateType) { } public static TDelegate CreateDelegateToMixin(object proxy) { } - public static object GetUnproxiedInstance(object instance) { } + public static object? GetUnproxiedInstance(object instance) { } public static System.Type GetUnproxiedType(object instance) { } public static bool IsAccessible(System.Reflection.MethodBase method) { } public static bool IsAccessible(System.Type type) { } - public static bool IsAccessible(System.Reflection.MethodBase method, out string message) { } - public static bool IsProxy(object instance) { } + public static bool IsAccessible(System.Reflection.MethodBase method, [System.Diagnostics.CodeAnalysis.NotNullWhen(false)] out string? message) { } + public static bool IsProxy(object? instance) { } public static bool IsProxyType(System.Type type) { } } public class StandardInterceptor : Castle.DynamicProxy.IInterceptor @@ -2738,17 +2739,17 @@ namespace Castle.DynamicProxy.Internal { public abstract class CompositionInvocation : Castle.DynamicProxy.AbstractInvocation { - protected object target; - protected CompositionInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + protected object? target; + protected CompositionInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected void EnsureValidProxyTarget(object newTarget) { } protected void EnsureValidTarget() { } } public abstract class InheritanceInvocation : Castle.DynamicProxy.AbstractInvocation { - protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } + protected InheritanceInvocation(System.Type targetType, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } public override object InvocationTarget { get; } public override System.Reflection.MethodInfo MethodInvocationTarget { get; } public override System.Type TargetType { get; } @@ -2761,16 +2762,16 @@ protected override void InvokeMethodOnTarget() { } } public sealed class InterfaceMethodWithoutTargetInvocation : Castle.DynamicProxy.AbstractInvocation { - public InterfaceMethodWithoutTargetInvocation(object target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object[] arguments) { } - public override object InvocationTarget { get; } - public override System.Reflection.MethodInfo MethodInvocationTarget { get; } - public override System.Type TargetType { get; } + public InterfaceMethodWithoutTargetInvocation(object? target, object proxy, Castle.DynamicProxy.IInterceptor[] interceptors, System.Reflection.MethodInfo proxiedMethod, object?[] arguments) { } + public override object? InvocationTarget { get; } + public override System.Reflection.MethodInfo? MethodInvocationTarget { get; } + public override System.Type? TargetType { get; } protected override void InvokeMethodOnTarget() { } } public static class TypeUtil { public static System.Type[] GetAllInterfaces(this System.Type type) { } - public static System.Type GetTypeOrNull(object target) { } + public static System.Type? GetTypeOrNull(object? target) { } public static System.Reflection.MemberInfo[] Sort(System.Reflection.MemberInfo[] members) { } } } \ No newline at end of file diff --git a/src/Castle.Core/Compatibility/NullStateStaticAnalysisAttributes.cs b/src/Castle.Core/Compatibility/NullStateStaticAnalysisAttributes.cs new file mode 100644 index 0000000000..7ed720ce42 --- /dev/null +++ b/src/Castle.Core/Compatibility/NullStateStaticAnalysisAttributes.cs @@ -0,0 +1,51 @@ +// Copyright 2004-2023 Castle Project - http://www.castleproject.org/ +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace System.Diagnostics.CodeAnalysis +{ + using System; + +#if !NETSTANDARD2_1_OR_GREATER && !NETCOREAPP3_0_OR_GREATER + [AttributeUsage(AttributeTargets.Method, Inherited = false)] + internal sealed class DoesNotReturnAttribute : Attribute + { + } +#endif + +#if !NET5_0_OR_GREATER + [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = true, Inherited = false)] + internal sealed class MemberNotNullAttribute : Attribute + { + public MemberNotNullAttribute(string member) + { + Members = new[] { member }; + } + + public string[] Members { get; } + } +#endif + +#if !NETSTANDARD2_1_OR_GREATER && !NETCOREAPP3_0_OR_GREATER + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + internal sealed class NotNullWhenAttribute : Attribute + { + public NotNullWhenAttribute(bool returnValue) + { + ReturnValue = returnValue; + } + + public bool ReturnValue { get; } + } +#endif +} diff --git a/src/Castle.Core/DynamicProxy/AbstractInvocation.cs b/src/Castle.Core/DynamicProxy/AbstractInvocation.cs index 30197b8613..6c04906402 100644 --- a/src/Castle.Core/DynamicProxy/AbstractInvocation.cs +++ b/src/Castle.Core/DynamicProxy/AbstractInvocation.cs @@ -12,18 +12,21 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; using System.Reflection; public abstract class AbstractInvocation : IInvocation { private readonly IInterceptor[] interceptors; - private readonly object[] arguments; + private readonly object?[] arguments; private int currentInterceptorIndex = -1; - private Type[] genericMethodArguments; + private Type[]? genericMethodArguments; private readonly MethodInfo proxiedMethod; protected readonly object proxyObject; @@ -31,9 +34,8 @@ protected AbstractInvocation( object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, - object[] arguments) + object?[] arguments) { - Debug.Assert(proxiedMethod != null); proxyObject = proxy; this.interceptors = interceptors; this.proxiedMethod = proxiedMethod; @@ -45,13 +47,13 @@ public void SetGenericMethodArguments(Type[] arguments) genericMethodArguments = arguments; } - public abstract object InvocationTarget { get; } + public abstract object? InvocationTarget { get; } - public abstract Type TargetType { get; } + public abstract Type? TargetType { get; } - public abstract MethodInfo MethodInvocationTarget { get; } + public abstract MethodInfo? MethodInvocationTarget { get; } - public Type[] GenericArguments + public Type[]? GenericArguments { get { return genericMethodArguments; } } @@ -71,7 +73,7 @@ public MethodInfo GetConcreteMethod() return EnsureClosedMethod(Method); } - public MethodInfo GetConcreteMethodInvocationTarget() + public MethodInfo? GetConcreteMethodInvocationTarget() { // it is ensured by the InvocationHelper that method will be closed var method = MethodInvocationTarget; @@ -80,19 +82,19 @@ public MethodInfo GetConcreteMethodInvocationTarget() return method; } - public object ReturnValue { get; set; } + public object? ReturnValue { get; set; } - public object[] Arguments + public object?[] Arguments { get { return arguments; } } - public void SetArgumentValue(int index, object value) + public void SetArgumentValue(int index, object? value) { arguments[index] = value; } - public object GetArgumentValue(int index) + public object? GetArgumentValue(int index) { return arguments[index]; } @@ -137,6 +139,7 @@ public IInvocationProceedInfo CaptureProceedInfo() protected abstract void InvokeMethodOnTarget(); + [DoesNotReturn] protected void ThrowOnNoTarget() { // let's try to build as friendly message as we can @@ -152,7 +155,7 @@ protected void ThrowOnNoTarget() string methodKindIs; string methodKindDescription; - if (Method.DeclaringType.IsClass && Method.IsAbstract) + if (Method.DeclaringType!.IsClass && Method.IsAbstract) { methodKindIs = "is abstract"; methodKindDescription = "an abstract method"; diff --git a/src/Castle.Core/DynamicProxy/AllMethodsHook.cs b/src/Castle.Core/DynamicProxy/AllMethodsHook.cs index 9424c149a0..bb11338cab 100644 --- a/src/Castle.Core/DynamicProxy/AllMethodsHook.cs +++ b/src/Castle.Core/DynamicProxy/AllMethodsHook.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -32,7 +34,7 @@ public class AllMethodsHook : IProxyGenerationHook public virtual bool ShouldInterceptMethod(Type type, MethodInfo methodInfo) { - return SkippedTypes.Contains(methodInfo.DeclaringType) == false; + return SkippedTypes.Contains(methodInfo.DeclaringType!) == false; } public virtual void NonProxyableMemberNotification(Type type, MemberInfo memberInfo) @@ -43,7 +45,7 @@ public virtual void MethodsInspected() { } - public override bool Equals(object obj) + public override bool Equals(object? obj) { return obj != null && obj.GetType() == GetType(); } diff --git a/src/Castle.Core/DynamicProxy/CustomAttributeInfo.cs b/src/Castle.Core/DynamicProxy/CustomAttributeInfo.cs index 1277b86098..68ac6c765e 100644 --- a/src/Castle.Core/DynamicProxy/CustomAttributeInfo.cs +++ b/src/Castle.Core/DynamicProxy/CustomAttributeInfo.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -34,26 +36,26 @@ public class CustomAttributeInfo : IEquatable // Cached empty arrays to avoid unnecessary allocations private static readonly PropertyInfo[] EmptyProperties = new PropertyInfo[0]; private static readonly FieldInfo[] EmptyFields = new FieldInfo[0]; - private static readonly object[] EmptyValues = new object[0]; + private static readonly object?[] EmptyValues = new object?[0]; - private static readonly IEqualityComparer ValueComparer = new AttributeArgumentValueEqualityComparer(); + private static readonly AttributeArgumentValueEqualityComparer ValueComparer = new AttributeArgumentValueEqualityComparer(); private readonly CustomAttributeBuilder builder; private readonly ConstructorInfo constructor; - private readonly object[] constructorArgs; - private readonly IDictionary properties; - private readonly IDictionary fields; + private readonly object?[] constructorArgs; + private readonly IDictionary properties; + private readonly IDictionary fields; public CustomAttributeInfo( ConstructorInfo constructor, - object[] constructorArgs, + object?[] constructorArgs, PropertyInfo[] namedProperties, - object[] propertyValues, + object?[] propertyValues, FieldInfo[] namedFields, - object[] fieldValues) + object?[] fieldValues) { // Will take care of validating the arguments - this.builder = new CustomAttributeBuilder(constructor, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues); + this.builder = new CustomAttributeBuilder(constructor, constructorArgs, namedProperties, propertyValues!, namedFields, fieldValues!); this.constructor = constructor; this.constructorArgs = constructorArgs.Length == 0 ? EmptyValues : constructorArgs.ToArray(); @@ -63,25 +65,25 @@ public CustomAttributeInfo( public CustomAttributeInfo( ConstructorInfo constructor, - object[] constructorArgs, + object?[] constructorArgs, PropertyInfo[] namedProperties, - object[] propertyValues) + object?[] propertyValues) : this(constructor, constructorArgs, namedProperties, propertyValues, EmptyFields, EmptyValues) { } public CustomAttributeInfo( ConstructorInfo constructor, - object[] constructorArgs, + object?[] constructorArgs, FieldInfo[] namedFields, - object[] fieldValues) + object?[] fieldValues) : this(constructor, constructorArgs, EmptyProperties, EmptyValues, namedFields, fieldValues) { } public CustomAttributeInfo( ConstructorInfo constructor, - object[] constructorArgs) + object?[] constructorArgs) : this(constructor, constructorArgs, EmptyProperties, EmptyValues, EmptyFields, EmptyValues) { } @@ -89,9 +91,9 @@ public CustomAttributeInfo( public static CustomAttributeInfo FromExpression(Expression> expression) { var namedProperties = new List(); - var propertyValues = new List(); + var propertyValues = new List(); var namedFields = new List(); - var fieldValues = new List(); + var fieldValues = new List(); var body = UnwrapBody(expression.Body); @@ -114,7 +116,7 @@ public static CustomAttributeInfo FromExpression(Expression> exp throw new ArgumentException("Only assignment bindings are supported"); } - object value = GetAttributeArgumentValue(assignment.Expression, allowArray: true); + object? value = GetAttributeArgumentValue(assignment.Expression, allowArray: true); var property = assignment.Member as PropertyInfo; if (property != null) @@ -138,15 +140,15 @@ public static CustomAttributeInfo FromExpression(Expression> exp } } - var ctorArguments = new List(); + var ctorArguments = new List(); foreach (var arg in newExpression.Arguments) { - object value = GetAttributeArgumentValue(arg, allowArray: true); + object? value = GetAttributeArgumentValue(arg, allowArray: true); ctorArguments.Add(value); } return new CustomAttributeInfo( - newExpression.Constructor, + newExpression.Constructor!, ctorArguments.ToArray(), namedProperties.ToArray(), propertyValues.ToArray(), @@ -168,7 +170,7 @@ private static Expression UnwrapBody(Expression body) return body; } - private static object GetAttributeArgumentValue(Expression arg, bool allowArray) + private static object? GetAttributeArgumentValue(Expression arg, bool allowArray) { switch (arg.NodeType) { @@ -190,11 +192,11 @@ private static object GetAttributeArgumentValue(Expression arg, bool allowArray) if (allowArray) { var newArrayExpr = (NewArrayExpression) arg; - var array = Array.CreateInstance(newArrayExpr.Type.GetElementType(), newArrayExpr.Expressions.Count); + var array = Array.CreateInstance(newArrayExpr.Type.GetElementType()!, newArrayExpr.Expressions.Count); int index = 0; foreach (var expr in newArrayExpr.Expressions) { - object value = GetAttributeArgumentValue(expr, allowArray: false); + object? value = GetAttributeArgumentValue(expr, allowArray: false); array.SetValue(value, index); index++; } @@ -216,7 +218,7 @@ internal CustomAttributeBuilder Builder get { return builder; } } - public bool Equals(CustomAttributeInfo other) + public bool Equals(CustomAttributeInfo? other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; @@ -226,7 +228,7 @@ public bool Equals(CustomAttributeInfo other) AreMembersEquivalent(fields, other.fields); } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; @@ -246,14 +248,14 @@ public override int GetHashCode() } } - private static bool AreMembersEquivalent(IDictionary x, IDictionary y) + private static bool AreMembersEquivalent(IDictionary x, IDictionary y) { if (x.Count != y.Count) return false; foreach (var kvp in x) { - object value; + object? value; if (!y.TryGetValue(kvp.Key, out value)) return false; if (!ValueComparer.Equals(kvp.Value, value)) @@ -262,12 +264,12 @@ private static bool AreMembersEquivalent(IDictionary x, IDiction return true; } - private static int CombineHashCodes(IEnumerable values) + private static int CombineHashCodes(IEnumerable values) { unchecked { int hashCode = 173; - foreach (object value in values) + foreach (object? value in values) { hashCode = (hashCode*397) ^ ValueComparer.GetHashCode(value); } @@ -275,7 +277,7 @@ private static int CombineHashCodes(IEnumerable values) } } - private static int CombineMemberHashCodes(IDictionary dict) + private static int CombineMemberHashCodes(IDictionary dict) { unchecked { @@ -293,10 +295,10 @@ private static int CombineMemberHashCodes(IDictionary dict) } } - private IDictionary MakeNameValueDictionary(T[] members, object[] values) + private IDictionary MakeNameValueDictionary(T[] members, object?[] values) where T : MemberInfo { - var dict = new Dictionary(); + var dict = new Dictionary(); for (int i = 0; i < members.Length; i++) { dict.Add(members[i].Name, values[i]); @@ -304,9 +306,9 @@ private IDictionary MakeNameValueDictionary(T[] members, obje return dict; } - private class AttributeArgumentValueEqualityComparer : IEqualityComparer + private class AttributeArgumentValueEqualityComparer : IEqualityComparer { - bool IEqualityComparer.Equals(object x, object y) + new public bool Equals(object? x, object? y) { if (ReferenceEquals(x, y)) return true; @@ -323,7 +325,7 @@ bool IEqualityComparer.Equals(object x, object y) return x.Equals(y); } - int IEqualityComparer.GetHashCode(object obj) + public int GetHashCode(object? obj) { if (obj == null) return 0; @@ -334,13 +336,13 @@ int IEqualityComparer.GetHashCode(object obj) return obj.GetHashCode(); } - private static IEnumerable AsObjectEnumerable(object array) + private static IEnumerable AsObjectEnumerable(object array) { // Covariance doesn't work for value types - if (array.GetType().GetElementType().IsValueType) - return ((Array)array).Cast(); + if (array.GetType().GetElementType()!.IsValueType) + return ((Array)array).Cast(); - return (IEnumerable)array; + return (IEnumerable)array; } } } diff --git a/src/Castle.Core/DynamicProxy/DefaultProxyBuilder.cs b/src/Castle.Core/DynamicProxy/DefaultProxyBuilder.cs index c8454aa795..703e4aafb5 100644 --- a/src/Castle.Core/DynamicProxy/DefaultProxyBuilder.cs +++ b/src/Castle.Core/DynamicProxy/DefaultProxyBuilder.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -59,7 +61,7 @@ public ModuleScope ModuleScope get { return scope; } } - public Type CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options) + public Type CreateClassProxyType(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { AssertValidType(classToProxy, nameof(classToProxy)); AssertValidTypes(additionalInterfacesToProxy, nameof(additionalInterfacesToProxy)); @@ -69,7 +71,7 @@ public Type CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesT return generator.GetProxyType(); } - public Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, + public Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { AssertValidType(classToProxy, nameof(classToProxy)); @@ -81,7 +83,7 @@ public Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[] additionalI return generator.GetProxyType(); } - public Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + public Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, Type targetType, ProxyGenerationOptions options) { @@ -93,7 +95,7 @@ public Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] add return generator.GetProxyType(); } - public Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + public Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { AssertValidType(interfaceToProxy, nameof(interfaceToProxy)); @@ -104,7 +106,7 @@ public Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, T return generator.GetProxyType(); } - public Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + public Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { AssertValidType(interfaceToProxy, nameof(interfaceToProxy)); @@ -150,7 +152,7 @@ private void AssertValidTypeForTarget(Type type, Type target, string paramName) } } - private void AssertValidTypes(IEnumerable targetTypes, string paramName) + private void AssertValidTypes(IEnumerable? targetTypes, string paramName) { if (targetTypes != null) { diff --git a/src/Castle.Core/DynamicProxy/DynamicProxyException.cs b/src/Castle.Core/DynamicProxy/DynamicProxyException.cs index 56f5b7a427..6fbb4f943e 100644 --- a/src/Castle.Core/DynamicProxy/DynamicProxyException.cs +++ b/src/Castle.Core/DynamicProxy/DynamicProxyException.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; diff --git a/src/Castle.Core/DynamicProxy/IChangeProxyTarget.cs b/src/Castle.Core/DynamicProxy/IChangeProxyTarget.cs index 8250203299..1bf4da16fc 100644 --- a/src/Castle.Core/DynamicProxy/IChangeProxyTarget.cs +++ b/src/Castle.Core/DynamicProxy/IChangeProxyTarget.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -36,7 +38,7 @@ public interface IChangeProxyTarget /// cref = "InvalidOperationException" /> will be throws. /// /// Thrown when is not assignable to the proxied type. - void ChangeInvocationTarget(object target); + void ChangeInvocationTarget(object? target); /// /// Permanently changes the target object of the proxy. This does not affect target of the current invocation. @@ -54,6 +56,6 @@ public interface IChangeProxyTarget /// /// Thrown when is not assignable to the proxied type. [Obsolete("Use ((IProxyTargetAccessor)invocation.Proxy).DynProxySetTarget(target) instead.")] - void ChangeProxyTarget(object target); + void ChangeProxyTarget(object? target); } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/IInterceptor.cs b/src/Castle.Core/DynamicProxy/IInterceptor.cs index f5f4378d04..941b936bb1 100644 --- a/src/Castle.Core/DynamicProxy/IInterceptor.cs +++ b/src/Castle.Core/DynamicProxy/IInterceptor.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { /// diff --git a/src/Castle.Core/DynamicProxy/IInterceptorSelector.cs b/src/Castle.Core/DynamicProxy/IInterceptorSelector.cs index 86d46bdd42..ce1d5f6001 100644 --- a/src/Castle.Core/DynamicProxy/IInterceptorSelector.cs +++ b/src/Castle.Core/DynamicProxy/IInterceptorSelector.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -37,6 +39,6 @@ public interface IInterceptorSelector /// legal to return other implementations than these provided in /// . /// - IInterceptor[] SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors); + IInterceptor[]? SelectInterceptors(Type type, MethodInfo method, IInterceptor[] interceptors); } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/IInvocation.cs b/src/Castle.Core/DynamicProxy/IInvocation.cs index 861eaab2de..839edfa0b5 100644 --- a/src/Castle.Core/DynamicProxy/IInvocation.cs +++ b/src/Castle.Core/DynamicProxy/IInvocation.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -26,13 +28,13 @@ public interface IInvocation /// Gets the arguments that the has been invoked with. /// /// The arguments the method was invoked with. - object[] Arguments { get; } + object?[] Arguments { get; } /// /// Gets the generic arguments of the method. /// /// The generic arguments, or null if not a generic method. - Type[] GenericArguments { get; } + Type[]? GenericArguments { get; } /// /// Gets the object on which the invocation is performed. This is different from proxy object @@ -40,7 +42,7 @@ public interface IInvocation /// /// /// The invocation target. - object InvocationTarget { get; } + object? InvocationTarget { get; } /// /// Gets the representing the method being invoked on the proxy. @@ -52,7 +54,7 @@ public interface IInvocation /// For interface proxies, this will point to the on the target class. /// /// The method invocation target. - MethodInfo MethodInvocationTarget { get; } + MethodInfo? MethodInvocationTarget { get; } /// /// Gets the proxy object on which the intercepted method is invoked. @@ -64,20 +66,20 @@ public interface IInvocation /// Gets or sets the return value of the method. /// /// The return value of the method. - object ReturnValue { get; set; } + object? ReturnValue { get; set; } /// /// Gets the type of the target object for the intercepted method. /// /// The type of the target object. - Type TargetType { get; } + Type? TargetType { get; } /// /// Gets the value of the argument at the specified . /// /// The index. /// The value of the argument at the specified . - object GetArgumentValue(int index); + object? GetArgumentValue(int index); /// /// Returns the concrete instantiation of the on the proxy, with any generic @@ -102,7 +104,7 @@ public interface IInvocation /// /// In debug builds this can be slower than calling . /// - MethodInfo GetConcreteMethodInvocationTarget(); + MethodInfo? GetConcreteMethodInvocationTarget(); /// /// Proceeds the call to the next interceptor in line, and ultimately to the target method. @@ -130,6 +132,6 @@ public interface IInvocation /// /// The index of the argument to override. /// The new value for the argument. - void SetArgumentValue(int index, object value); + void SetArgumentValue(int index, object? value); } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/IInvocationProceedInfo.cs b/src/Castle.Core/DynamicProxy/IInvocationProceedInfo.cs index 499479833e..9ba47524e1 100644 --- a/src/Castle.Core/DynamicProxy/IInvocationProceedInfo.cs +++ b/src/Castle.Core/DynamicProxy/IInvocationProceedInfo.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; diff --git a/src/Castle.Core/DynamicProxy/IProxyBuilder.cs b/src/Castle.Core/DynamicProxy/IProxyBuilder.cs index 84a525b257..46a436ccf2 100644 --- a/src/Castle.Core/DynamicProxy/IProxyBuilder.cs +++ b/src/Castle.Core/DynamicProxy/IProxyBuilder.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -57,9 +59,9 @@ public interface IProxyBuilder /// cref = "InternalsVisibleToAttribute" /> /// pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate. /// - Type CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options); + Type CreateClassProxyType(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options); - Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, + Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options); /// @@ -85,7 +87,7 @@ Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[] additionalInterfac /// cref = "InternalsVisibleToAttribute" /> /// pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate. /// - Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, Type targetType, + Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, Type targetType, ProxyGenerationOptions options); /// @@ -110,7 +112,7 @@ Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] additional /// cref = "InternalsVisibleToAttribute" /> /// pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate. /// - Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options); /// @@ -131,7 +133,7 @@ Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[] a /// cref = "InternalsVisibleToAttribute" /> /// pointing to Castle Dynamic Proxy assembly, in assembly containing that type, if this is appropriate. /// - Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options); } } \ No newline at end of file diff --git a/src/Castle.Core/DynamicProxy/IProxyGenerationHook.cs b/src/Castle.Core/DynamicProxy/IProxyGenerationHook.cs index 93826e91b3..33e80ce96c 100644 --- a/src/Castle.Core/DynamicProxy/IProxyGenerationHook.cs +++ b/src/Castle.Core/DynamicProxy/IProxyGenerationHook.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; diff --git a/src/Castle.Core/DynamicProxy/IProxyGenerator.cs b/src/Castle.Core/DynamicProxy/IProxyGenerator.cs index 14403dc27d..2224e9a441 100644 --- a/src/Castle.Core/DynamicProxy/IProxyGenerator.cs +++ b/src/Castle.Core/DynamicProxy/IProxyGenerator.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -179,7 +181,7 @@ object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object target, Prox /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, object target, + object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, object target, params IInterceptor[] interceptors); /// @@ -213,7 +215,7 @@ object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalIn /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, object target, ProxyGenerationOptions options, params IInterceptor[] interceptors); @@ -231,7 +233,6 @@ object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalIn /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is a generic type definition. /// Thrown when given is not an interface type. @@ -245,7 +246,7 @@ object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalIn /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object target, + object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object? target, params IInterceptor[] interceptors); /// @@ -260,7 +261,6 @@ object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object tar /// /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is not an interface type. /// Thrown when no default constructor exists on actual type of implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params IInterceptor[] interceptors) where TInterface : class; @@ -288,7 +288,6 @@ TInterface CreateInterfaceProxyWithTargetInterface(TInterface target /// /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is not an interface type. /// Thrown when no default constructor exists on actual type of (TInterface target /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, + TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) where TInterface : class; @@ -319,7 +318,6 @@ TInterface CreateInterfaceProxyWithTargetInterface(TInterface target /// name = "additionalInterfacesToProxy" /> types on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given or any of is a generic type definition. @@ -334,8 +332,8 @@ TInterface CreateInterfaceProxyWithTargetInterface(TInterface target /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Type[] additionalInterfacesToProxy, - object target, params IInterceptor[] interceptors); + object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, + object? target, params IInterceptor[] interceptors); /// /// Creates proxy object intercepting calls to members of interface on type on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is a generic type definition. /// Thrown when given is not an interface type. @@ -365,7 +362,7 @@ object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Type[] add /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object target, + object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors); @@ -382,7 +379,6 @@ object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object tar /// Object proxying calls to members of and types on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given or any of is a generic type definition. /// Thrown when given is not an interface type. @@ -394,8 +390,8 @@ object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object tar /// As such caller should expect any type of exception that given implementation may throw. /// object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, - Type[] additionalInterfacesToProxy, - object target, ProxyGenerationOptions options, + Type[]? additionalInterfacesToProxy, + object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors); /// @@ -539,7 +535,7 @@ TInterface CreateInterfaceProxyWithoutTarget(ProxyGenerationOptions /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, params IInterceptor[] interceptors); /// @@ -590,7 +586,7 @@ object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, ProxyGenerationO /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options, params IInterceptor[] interceptors); @@ -612,7 +608,7 @@ object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additiona /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - TClass CreateClassProxyWithTarget(TClass target, params IInterceptor[] interceptors) + TClass CreateClassProxyWithTarget(TClass? target, params IInterceptor[] interceptors) where TClass : class; /// @@ -634,7 +630,7 @@ TClass CreateClassProxyWithTarget(TClass target, params IInterceptor[] i /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - TClass CreateClassProxyWithTarget(TClass target, ProxyGenerationOptions options, + TClass CreateClassProxyWithTarget(TClass? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) where TClass : class; /// @@ -659,7 +655,7 @@ TClass CreateClassProxyWithTarget(TClass target, ProxyGenerationOptions /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target, + object CreateClassProxyWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, object? target, params IInterceptor[] interceptors); /// @@ -685,8 +681,8 @@ object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfaces /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options, - object[] constructorArguments, params IInterceptor[] interceptors); + object CreateClassProxyWithTarget(Type classToProxy, object? target, ProxyGenerationOptions options, + object?[]? constructorArguments, params IInterceptor[] interceptors); /// /// Creates proxy object intercepting calls to virtual members of type on newly created instance of that type with given implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, object target, object[] constructorArguments, + object CreateClassProxyWithTarget(Type classToProxy, object? target, object?[]? constructorArguments, params IInterceptor[] interceptors); /// @@ -734,7 +730,7 @@ object CreateClassProxyWithTarget(Type classToProxy, object target, object[] con /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, object target, params IInterceptor[] interceptors); + object CreateClassProxyWithTarget(Type classToProxy, object? target, params IInterceptor[] interceptors); /// /// Creates proxy object intercepting calls to virtual members of type on newly created instance of that type with given implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options, + object CreateClassProxyWithTarget(Type classToProxy, object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors); /// @@ -785,7 +781,7 @@ object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerat /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target, + object CreateClassProxyWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors); /// @@ -814,8 +810,8 @@ object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfaces /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target, - ProxyGenerationOptions options, object[] constructorArguments, + object CreateClassProxyWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, object? target, + ProxyGenerationOptions options, object?[]? constructorArguments, params IInterceptor[] interceptors); /// @@ -879,7 +875,7 @@ TClass CreateClassProxy(ProxyGenerationOptions options, params IIntercep /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, + object CreateClassProxy(Type classToProxy, Type[]? additionalInterfacesToProxy, params IInterceptor[] interceptors); /// @@ -904,7 +900,7 @@ object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options, object[] constructorArguments, + object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options, object?[]? constructorArguments, params IInterceptor[] interceptors); /// @@ -928,7 +924,7 @@ object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options, objec /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxy(Type classToProxy, object[] constructorArguments, params IInterceptor[] interceptors); + object CreateClassProxy(Type classToProxy, object?[]? constructorArguments, params IInterceptor[] interceptors); /// /// Creates proxy object intercepting calls to virtual members of type on newly created instance of that type with given implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, + object CreateClassProxy(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options, params IInterceptor[] interceptors); /// @@ -1026,9 +1022,9 @@ object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, P /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, + object CreateClassProxy(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options, - object[] constructorArguments, params IInterceptor[] interceptors); + object?[]? constructorArguments, params IInterceptor[] interceptors); /// /// Creates proxy object intercepting calls to virtual members of type on newly created instance of that type with given implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TClass CreateClassProxy(ProxyGenerationOptions options, object[] constructorArguments, params IInterceptor[] interceptors) where TClass : class; + public TClass CreateClassProxy(ProxyGenerationOptions options, object?[]? constructorArguments, params IInterceptor[] interceptors) where TClass : class; /// /// Creates proxy object intercepting calls to virtual members of type on newly created instance of that type with given implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TClass CreateClassProxy(object[] constructorArguments, params IInterceptor[] interceptors) where TClass : class; + public TClass CreateClassProxy(object?[]? constructorArguments, params IInterceptor[] interceptors) where TClass : class; } } diff --git a/src/Castle.Core/DynamicProxy/IProxyTargetAccessor.cs b/src/Castle.Core/DynamicProxy/IProxyTargetAccessor.cs index 172618ee41..4ca4cbc18f 100644 --- a/src/Castle.Core/DynamicProxy/IProxyTargetAccessor.cs +++ b/src/Castle.Core/DynamicProxy/IProxyTargetAccessor.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { /// @@ -23,13 +25,13 @@ public interface IProxyTargetAccessor /// /// Get the proxy target (note that null is a valid target!) /// - object DynProxyGetTarget(); + object? DynProxyGetTarget(); /// /// Set the proxy target. /// /// New proxy target. - void DynProxySetTarget(object target); + void DynProxySetTarget(object? target); /// /// Gets the interceptors for the proxy diff --git a/src/Castle.Core/DynamicProxy/Internal/CompositionInvocation.cs b/src/Castle.Core/DynamicProxy/Internal/CompositionInvocation.cs index 0d03e564b0..c9e70bd4cf 100644 --- a/src/Castle.Core/DynamicProxy/Internal/CompositionInvocation.cs +++ b/src/Castle.Core/DynamicProxy/Internal/CompositionInvocation.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy.Internal { using System; @@ -19,30 +21,30 @@ namespace Castle.DynamicProxy.Internal public abstract class CompositionInvocation : AbstractInvocation { - protected object target; + protected object? target; protected CompositionInvocation( - object target, + object? target, object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, - object[] arguments) + object?[] arguments) : base(proxy, interceptors, proxiedMethod, arguments) { this.target = target; } - public override object InvocationTarget + public override object? InvocationTarget { get { return target; } } - public override MethodInfo MethodInvocationTarget + public override MethodInfo? MethodInvocationTarget { get { return InvocationHelper.GetMethodOnObject(target, Method); } } - public override Type TargetType + public override Type? TargetType { get { return TypeUtil.GetTypeOrNull(target); } } diff --git a/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocation.cs b/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocation.cs index a3a6d7fe91..a1572fb7b0 100644 --- a/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocation.cs +++ b/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocation.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy.Internal { using System; @@ -26,7 +28,7 @@ protected InheritanceInvocation( object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, - object[] arguments) + object?[] arguments) : base(proxy, interceptors, proxiedMethod, arguments) { this.targetType = targetType; diff --git a/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocationWithoutTarget.cs b/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocationWithoutTarget.cs index 10066ac405..dea052dca5 100644 --- a/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocationWithoutTarget.cs +++ b/src/Castle.Core/DynamicProxy/Internal/InheritanceInvocationWithoutTarget.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy.Internal { using System; diff --git a/src/Castle.Core/DynamicProxy/Internal/InterfaceMethodWithoutTargetInvocation.cs b/src/Castle.Core/DynamicProxy/Internal/InterfaceMethodWithoutTargetInvocation.cs index a1c92a2dc9..b03704533e 100644 --- a/src/Castle.Core/DynamicProxy/Internal/InterfaceMethodWithoutTargetInvocation.cs +++ b/src/Castle.Core/DynamicProxy/Internal/InterfaceMethodWithoutTargetInvocation.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy.Internal { using System; @@ -25,7 +27,7 @@ namespace Castle.DynamicProxy.Internal [EditorBrowsable(EditorBrowsableState.Never)] public sealed class InterfaceMethodWithoutTargetInvocation : AbstractInvocation { - public InterfaceMethodWithoutTargetInvocation(object target, object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, object[] arguments) + public InterfaceMethodWithoutTargetInvocation(object? target, object proxy, IInterceptor[] interceptors, MethodInfo proxiedMethod, object?[] arguments) : base(proxy, interceptors, proxiedMethod, arguments) { // This invocation type is suitable for interface method invocations that cannot proceed @@ -50,11 +52,11 @@ public InterfaceMethodWithoutTargetInvocation(object target, object proxy, IInte // (This is why this type's name starts with `Interface`.) A similar type could be written // for class proxies without target, but the values returned here would be different. - public override object InvocationTarget => null; + public override object? InvocationTarget => null; - public override MethodInfo MethodInvocationTarget => null; + public override MethodInfo? MethodInvocationTarget => null; - public override Type TargetType => null; + public override Type? TargetType => null; protected override void InvokeMethodOnTarget() => ThrowOnNoTarget(); } diff --git a/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs b/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs index 4abb205cd5..5a004ff1f0 100644 --- a/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs +++ b/src/Castle.Core/DynamicProxy/Internal/TypeUtil.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy.Internal { using System; @@ -51,10 +53,9 @@ internal static FieldInfo[] GetAllFields(this Type type) var currentType = type; while (currentType != typeof(object)) { - Debug.Assert(currentType != null); var currentFields = currentType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); fields.AddRange(currentFields); - currentType = currentType.BaseType; + currentType = currentType.BaseType!; } return fields.ToArray(); @@ -66,7 +67,7 @@ internal static FieldInfo[] GetAllFields(this Type type) /// internal static MethodInfo[] GetAllInstanceMethods(this Type type) { - MethodInfo[] methodsInCache; + MethodInfo[]? methodsInCache; lock (instanceMethodsCache) { @@ -85,7 +86,7 @@ internal static MethodInfo[] GetAllInstanceMethods(this Type type) /// /// Returns list of all unique interfaces implemented given types, including their base interfaces. /// - internal static Type[] GetAllInterfaces(params Type[] types) + internal static Type[] GetAllInterfaces(params Type[]? types) { if (types == null) { @@ -126,7 +127,7 @@ public static Type[] GetAllInterfaces(this Type type) // NOTE: also used by Win } - public static Type GetTypeOrNull(object target) + public static Type? GetTypeOrNull(object? target) { if (target == null) { @@ -186,11 +187,11 @@ internal static bool IsMemberwiseClone(this MethodInfo methodInfo) return methodInfo.DeclaringType == typeof(object) && string.Equals("MemberwiseClone", methodInfo.Name, StringComparison.OrdinalIgnoreCase); } - internal static void SetStaticField(this Type type, string fieldName, BindingFlags additionalFlags, object value) + internal static void SetStaticField(this Type type, string fieldName, BindingFlags additionalFlags, object? value) { var flags = additionalFlags | BindingFlags.Static; - FieldInfo field = type.GetField(fieldName, flags); + FieldInfo? field = type.GetField(fieldName, flags); if (field == null) { throw new DynamicProxyException(string.Format( @@ -264,13 +265,13 @@ private sealed class TypeNameComparer : IComparer { public static readonly TypeNameComparer Instance = new TypeNameComparer(); - public int Compare(Type x, Type y) + public int Compare(Type? x, Type? y) { // Comparing by `type.AssemblyQualifiedName` would give the same result, // but it performs a hidden concatenation (and therefore string allocation) // of `type.FullName` and `type.Assembly.FullName`. We can avoid this // overhead by comparing the two properties separately. - int result = string.CompareOrdinal(x.FullName, y.FullName); + int result = string.CompareOrdinal(x!.FullName, y!.FullName); return result != 0 ? result : string.CompareOrdinal(x.Assembly.FullName, y.Assembly.FullName); } } diff --git a/src/Castle.Core/DynamicProxy/MixinData.cs b/src/Castle.Core/DynamicProxy/MixinData.cs index 2d26f51a54..012b643ca3 100644 --- a/src/Castle.Core/DynamicProxy/MixinData.cs +++ b/src/Castle.Core/DynamicProxy/MixinData.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -26,7 +28,7 @@ namespace Castle.DynamicProxy public class MixinData { private readonly Dictionary mixinPositions = new Dictionary(); - private readonly List mixinsImpl = new List(); + private readonly List mixinsImpl = new List(); private int delegateMixinCount = 0; /// @@ -38,18 +40,18 @@ public class MixinData /// The idea is to have reproducible behavior for the case that mixins are registered in different orders. /// This method is here because it is required /// - public MixinData(IEnumerable mixinInstances) + public MixinData(IEnumerable? mixinInstances) { if (mixinInstances != null) { var sortedMixedInterfaceTypes = new List(); - var interface2Mixin = new Dictionary(); + var interface2Mixin = new Dictionary(); delegateMixinCount = 0; foreach (var mixin in mixinInstances) { Type[] mixinInterfaces; - object target; + object? target; if (mixin is Delegate) { ++delegateMixinCount; @@ -105,7 +107,7 @@ public MixinData(IEnumerable mixinInstances) { if (mixedInType.IsDelegateType()) { - var invokeMethod = mixedInType.GetMethod("Invoke"); + var invokeMethod = mixedInType.GetMethod("Invoke")!; if (invokeMethods.Contains(invokeMethod, MethodSignatureComparer.Instance)) { throw new ArgumentException("The list of mixins contains at least two delegate mixins for the same delegate signature.", nameof(mixinInstances)); @@ -133,7 +135,7 @@ public IEnumerable MixinInterfaces get { return mixinPositions.Keys; } } - public IEnumerable Mixins + public IEnumerable Mixins { get { return mixinsImpl; } } @@ -144,7 +146,7 @@ public bool ContainsMixin(Type mixinInterfaceType) } // For two MixinData objects being regarded equal, only the sorted mixin types are considered, not the actual instances. - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) { @@ -197,7 +199,7 @@ public override int GetHashCode() return hashCode; } - public object GetMixinInstance(Type mixinInterfaceType) + public object? GetMixinInstance(Type mixinInterfaceType) { return mixinsImpl[mixinPositions[mixinInterfaceType]]; } diff --git a/src/Castle.Core/DynamicProxy/ModuleScope.cs b/src/Castle.Core/DynamicProxy/ModuleScope.cs index b70b10984e..af17ae2eb9 100644 --- a/src/Castle.Core/DynamicProxy/ModuleScope.cs +++ b/src/Castle.Core/DynamicProxy/ModuleScope.cs @@ -12,11 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; using System.Collections.Generic; using System.Diagnostics; + using System.Diagnostics.CodeAnalysis; using System.IO; using System.Reflection; using System.Reflection.Emit; @@ -41,8 +44,8 @@ public class ModuleScope /// public static readonly string DEFAULT_ASSEMBLY_NAME = "DynamicProxyGenAssembly2"; - private ModuleBuilder moduleBuilderWithStrongName; - private ModuleBuilder moduleBuilder; + private ModuleBuilder? moduleBuilderWithStrongName; + private ModuleBuilder? moduleBuilder; // The names to use for the generated assemblies and the paths (including the names) of their manifest modules private readonly string strongAssemblyName; @@ -171,7 +174,7 @@ public static byte[] GetKeyPair() /// Gets the strong-named module generated by this scope, or if none has yet been generated. /// /// The strong-named module generated by this scope, or if none has yet been generated. - internal ModuleBuilder StrongNamedModule + internal ModuleBuilder? StrongNamedModule { get { return moduleBuilderWithStrongName; } } @@ -193,7 +196,7 @@ public string StrongNamedModuleName /// The directory where the strongly named module generated by this scope will be saved when is called /// (if this scope was created to save modules). - public string StrongNamedModuleDirectory + public string? StrongNamedModuleDirectory { get { @@ -211,7 +214,7 @@ public string StrongNamedModuleDirectory /// Gets the weak-named module generated by this scope, or if none has yet been generated. /// /// The weak-named module generated by this scope, or if none has yet been generated. - internal ModuleBuilder WeakNamedModule + internal ModuleBuilder? WeakNamedModule { get { return moduleBuilder; } } @@ -233,7 +236,7 @@ public string WeakNamedModuleName /// The directory where the weakly named module generated by this scope will be saved when is called /// (if this scope was created to save modules). - public string WeakNamedModuleDirectory + public string? WeakNamedModuleDirectory { get { @@ -267,6 +270,7 @@ internal ModuleBuilder ObtainDynamicModule(bool isStrongNamed) /// Gets the strong-named module generated by this scope, creating a new one if none has yet been generated. /// /// A strong-named module generated by this scope. + [MemberNotNull(nameof(moduleBuilderWithStrongName))] internal ModuleBuilder ObtainDynamicModuleWithStrongName() { if (disableSignedModule) @@ -288,6 +292,7 @@ internal ModuleBuilder ObtainDynamicModuleWithStrongName() /// Gets the weak-named module generated by this scope, creating a new one if none has yet been generated. /// /// A weak-named module generated by this scope. + [MemberNotNull(nameof(moduleBuilder))] internal ModuleBuilder ObtainDynamicModuleWithWeakName() { lock (moduleLocker) @@ -380,7 +385,7 @@ private AssemblyName GetAssemblyName(bool signStrongName) /// /// Both a strong-named and a weak-named assembly have been generated. /// The path of the generated assembly file, or null if no file has been generated. - public string SaveAssembly() + public string? SaveAssembly() { if (!savePhysicalAssembly) { @@ -426,7 +431,7 @@ public string SaveAssembly() /// name = "strongNamed" /> parameter. /// /// The path of the generated assembly file, or null if no file has been generated. - public string SaveAssembly(bool strongNamed) + public string? SaveAssembly(bool strongNamed) { if (!savePhysicalAssembly) { diff --git a/src/Castle.Core/DynamicProxy/PersistentProxyBuilder.cs b/src/Castle.Core/DynamicProxy/PersistentProxyBuilder.cs index c874f9bc33..4c591132de 100644 --- a/src/Castle.Core/DynamicProxy/PersistentProxyBuilder.cs +++ b/src/Castle.Core/DynamicProxy/PersistentProxyBuilder.cs @@ -14,6 +14,8 @@ #if FEATURE_ASSEMBLYBUILDER_SAVE +#nullable enable + namespace Castle.DynamicProxy { /// @@ -39,7 +41,7 @@ public PersistentProxyBuilder() : base(new ModuleScope(true)) /// This method does not support saving multiple files. If both a signed and an unsigned module have been generated, use the /// respective methods of the . /// - public string SaveAssembly() + public string? SaveAssembly() { return ModuleScope.SaveAssembly(); } diff --git a/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs b/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs index 515de4bef0..2dbe74aaba 100644 --- a/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs +++ b/src/Castle.Core/DynamicProxy/ProxyGenerationOptions.cs @@ -12,10 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Reflection.Emit; @@ -43,13 +46,13 @@ public class ProxyGenerationOptions { public static readonly ProxyGenerationOptions Default = new ProxyGenerationOptions(); - private List mixins; + private List? mixins; private readonly IList additionalAttributes = new List(); #if FEATURE_SERIALIZATION [NonSerialized] #endif - private MixinData mixinData; // this is calculated dynamically on proxy type creation + private MixinData? mixinData; // this is calculated dynamically on proxy type creation /// /// Initializes a new instance of the class. @@ -79,6 +82,7 @@ private ProxyGenerationOptions(SerializationInfo info, StreamingContext context) } #endif + [MemberNotNull(nameof(mixinData))] public void Initialize() { if (mixinData == null) @@ -124,7 +128,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) /// has been used to create a proxy. /// /// - public IInterceptorSelector Selector { get; set; } + public IInterceptorSelector? Selector { get; set; } /// /// Gets or sets the class type from which generated interface proxy types will be derived. @@ -218,6 +222,7 @@ public void AddMixinInstance(object instance) AddMixinImpl(instance); } + [MemberNotNull(nameof(mixins))] private void AddMixinImpl(object instanceOrType) { if (mixins == null) @@ -244,7 +249,7 @@ public bool HasMixins get { return mixins != null && mixins.Count != 0; } } - public override bool Equals(object obj) + public override bool Equals(object? obj) { if (ReferenceEquals(this, obj)) { diff --git a/src/Castle.Core/DynamicProxy/ProxyGenerator.cs b/src/Castle.Core/DynamicProxy/ProxyGenerator.cs index 159433255c..2074dce620 100644 --- a/src/Castle.Core/DynamicProxy/ProxyGenerator.cs +++ b/src/Castle.Core/DynamicProxy/ProxyGenerator.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; @@ -242,7 +244,7 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, object targe /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, object target, + public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, object target, params IInterceptor[] interceptors) { return CreateInterfaceProxyWithTarget(interfaceToProxy, additionalInterfacesToProxy, target, @@ -280,7 +282,7 @@ public object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] addit /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public virtual object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + public virtual object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, object target, ProxyGenerationOptions options, params IInterceptor[] interceptors) @@ -316,14 +318,14 @@ public virtual object CreateInterfaceProxyWithTarget(Type interfaceToProxy, Type options); var arguments = GetConstructorArguments(target, interceptors, options); - return Activator.CreateInstance(generatedType, arguments.ToArray()); + return Activator.CreateInstance(generatedType, arguments.ToArray())!; } - protected List GetConstructorArguments(object target, IInterceptor[] interceptors, - ProxyGenerationOptions options) + protected List GetConstructorArguments(object? target, IInterceptor[] interceptors, + ProxyGenerationOptions options) { // create constructor arguments (initialized with mixin implementations, interceptors and target type constructor arguments) - var arguments = new List(options.MixinData.Mixins) { interceptors, target }; + var arguments = new List(options.MixinData.Mixins) { interceptors, target }; if (options.Selector != null) { arguments.Add(options.Selector); @@ -344,7 +346,6 @@ protected List GetConstructorArguments(object target, IInterceptor[] int /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is a generic type definition. /// Thrown when given is not an interface type. @@ -358,7 +359,7 @@ protected List GetConstructorArguments(object target, IInterceptor[] int /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object target, + public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object? target, params IInterceptor[] interceptors) { return CreateInterfaceProxyWithTargetInterface(interfaceToProxy, target, ProxyGenerationOptions.Default, interceptors); @@ -376,7 +377,6 @@ public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, obj /// /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is not an interface type. /// Thrown when no default constructor exists on actual type of implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, params IInterceptor[] interceptors) where TInterface : class { @@ -410,7 +410,6 @@ public TInterface CreateInterfaceProxyWithTargetInterface(TInterface /// /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is not an interface type. /// Thrown when no default constructor exists on actual type of (TInterface /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TInterface CreateInterfaceProxyWithTargetInterface(TInterface target, + public TInterface CreateInterfaceProxyWithTargetInterface(TInterface? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) where TInterface : class @@ -447,7 +446,6 @@ public TInterface CreateInterfaceProxyWithTargetInterface(TInterface /// name = "additionalInterfacesToProxy" /> types on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given or any of is a generic type definition. @@ -462,8 +460,8 @@ public TInterface CreateInterfaceProxyWithTargetInterface(TInterface /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Type[] additionalInterfacesToProxy, - object target, params IInterceptor[] interceptors) + public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, + object? target, params IInterceptor[] interceptors) { return CreateInterfaceProxyWithTargetInterface(interfaceToProxy, additionalInterfacesToProxy, target, ProxyGenerationOptions.Default, interceptors); @@ -483,7 +481,6 @@ public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Typ /// Object proxying calls to members of type on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given is a generic type definition. /// Thrown when given is not an interface type. @@ -497,7 +494,7 @@ public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, Typ /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object target, + public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) { @@ -517,7 +514,6 @@ public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, obj /// Object proxying calls to members of and types on object or alternative implementation swapped at runtime by an interceptor. /// /// Thrown when given object is a null reference (Nothing in Visual Basic). - /// Thrown when given object is a null reference (Nothing in Visual Basic). /// Thrown when given array is a null reference (Nothing in Visual Basic). /// Thrown when given or any of is a generic type definition. /// Thrown when given is not an interface type. @@ -529,8 +525,8 @@ public object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, obj /// As such caller should expect any type of exception that given implementation may throw. /// public virtual object CreateInterfaceProxyWithTargetInterface(Type interfaceToProxy, - Type[] additionalInterfacesToProxy, - object target, ProxyGenerationOptions options, + Type[]? additionalInterfacesToProxy, + object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) { //TODO: add to xml comments to show how to use IChangeProxyTarget @@ -592,7 +588,7 @@ public virtual object CreateInterfaceProxyWithTargetInterface(Type interfaceToPr var generatedType = CreateInterfaceProxyTypeWithTargetInterface(interfaceToProxy, additionalInterfacesToProxy, options); var arguments = GetConstructorArguments(target, interceptors, options); - return Activator.CreateInstance(generatedType, arguments.ToArray()); + return Activator.CreateInstance(generatedType, arguments.ToArray())!; } /// @@ -753,7 +749,7 @@ public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, params II /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, params IInterceptor[] interceptors) { return CreateInterfaceProxyWithoutTarget(interfaceToProxy, additionalInterfacesToProxy, @@ -811,7 +807,7 @@ public object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, ProxyGene /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public virtual object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + public virtual object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options, params IInterceptor[] interceptors) { @@ -834,7 +830,7 @@ public virtual object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, T var generatedType = CreateInterfaceProxyTypeWithoutTarget(interfaceToProxy, additionalInterfacesToProxy, options); var arguments = GetConstructorArguments(null, interceptors, options); - return Activator.CreateInstance(generatedType, arguments.ToArray()); + return Activator.CreateInstance(generatedType, arguments.ToArray())!; } /// @@ -855,7 +851,7 @@ public virtual object CreateInterfaceProxyWithoutTarget(Type interfaceToProxy, T /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TClass CreateClassProxyWithTarget(TClass target, params IInterceptor[] interceptors) + public TClass CreateClassProxyWithTarget(TClass? target, params IInterceptor[] interceptors) where TClass : class { return (TClass)CreateClassProxyWithTarget(typeof(TClass), @@ -885,7 +881,7 @@ public TClass CreateClassProxyWithTarget(TClass target, params IIntercep /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TClass CreateClassProxyWithTarget(TClass target, ProxyGenerationOptions options, + public TClass CreateClassProxyWithTarget(TClass? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) where TClass : class { return (TClass)CreateClassProxyWithTarget(typeof(TClass), @@ -918,7 +914,7 @@ public TClass CreateClassProxyWithTarget(TClass target, ProxyGenerationO /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target, + public object CreateClassProxyWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, object? target, params IInterceptor[] interceptors) { return CreateClassProxyWithTarget(classToProxy, @@ -952,8 +948,8 @@ public object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInt /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options, - object[] constructorArguments, params IInterceptor[] interceptors) + public object CreateClassProxyWithTarget(Type classToProxy, object? target, ProxyGenerationOptions options, + object?[]? constructorArguments, params IInterceptor[] interceptors) { return CreateClassProxyWithTarget(classToProxy, Type.EmptyTypes, @@ -985,7 +981,7 @@ public object CreateClassProxyWithTarget(Type classToProxy, object target, Proxy /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxyWithTarget(Type classToProxy, object target, object[] constructorArguments, + public object CreateClassProxyWithTarget(Type classToProxy, object? target, object?[]? constructorArguments, params IInterceptor[] interceptors) { return CreateClassProxyWithTarget(classToProxy, @@ -1017,7 +1013,7 @@ public object CreateClassProxyWithTarget(Type classToProxy, object target, objec /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxyWithTarget(Type classToProxy, object target, params IInterceptor[] interceptors) + public object CreateClassProxyWithTarget(Type classToProxy, object? target, params IInterceptor[] interceptors) { return CreateClassProxyWithTarget(classToProxy, Type.EmptyTypes, @@ -1049,7 +1045,7 @@ public object CreateClassProxyWithTarget(Type classToProxy, object target, param /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxyWithTarget(Type classToProxy, object target, ProxyGenerationOptions options, + public object CreateClassProxyWithTarget(Type classToProxy, object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) { return CreateClassProxyWithTarget(classToProxy, @@ -1084,7 +1080,7 @@ public object CreateClassProxyWithTarget(Type classToProxy, object target, Proxy /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target, + public object CreateClassProxyWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, object? target, ProxyGenerationOptions options, params IInterceptor[] interceptors) { return CreateClassProxyWithTarget(classToProxy, @@ -1121,8 +1117,8 @@ public object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInt /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public virtual object CreateClassProxyWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, object target, - ProxyGenerationOptions options, object[] constructorArguments, + public virtual object CreateClassProxyWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, object? target, + ProxyGenerationOptions options, object?[]? constructorArguments, params IInterceptor[] interceptors) { if (classToProxy == null) @@ -1219,7 +1215,7 @@ public TClass CreateClassProxy(ProxyGenerationOptions options, params II /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TClass CreateClassProxy(ProxyGenerationOptions options, object[] constructorArguments, params IInterceptor[] interceptors) + public TClass CreateClassProxy(ProxyGenerationOptions options, object?[]? constructorArguments, params IInterceptor[] interceptors) where TClass : class { return (TClass)CreateClassProxy(typeof(TClass), options, constructorArguments, interceptors); @@ -1245,7 +1241,7 @@ public TClass CreateClassProxy(ProxyGenerationOptions options, object[] /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public TClass CreateClassProxy(object[] constructorArguments, params IInterceptor[] interceptors) + public TClass CreateClassProxy(object?[]? constructorArguments, params IInterceptor[] interceptors) where TClass : class { return (TClass)CreateClassProxy(typeof(TClass), constructorArguments, interceptors); @@ -1272,7 +1268,7 @@ public TClass CreateClassProxy(object[] constructorArguments, params IIn /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, + public object CreateClassProxy(Type classToProxy, Type[]? additionalInterfacesToProxy, params IInterceptor[] interceptors) { return CreateClassProxy(classToProxy, additionalInterfacesToProxy, ProxyGenerationOptions.Default, interceptors); @@ -1300,7 +1296,7 @@ public object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToP /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options, object[] constructorArguments, + public object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options, object?[]? constructorArguments, params IInterceptor[] interceptors) { return CreateClassProxy(classToProxy, null, options, constructorArguments, interceptors); @@ -1327,7 +1323,7 @@ public object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxy(Type classToProxy, object[] constructorArguments, params IInterceptor[] interceptors) + public object CreateClassProxy(Type classToProxy, object?[]? constructorArguments, params IInterceptor[] interceptors) { return CreateClassProxy(classToProxy, null, ProxyGenerationOptions.Default, constructorArguments, interceptors); } @@ -1407,7 +1403,7 @@ public object CreateClassProxy(Type classToProxy, ProxyGenerationOptions options /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, ProxyGenerationOptions options, + public object CreateClassProxy(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options, params IInterceptor[] interceptors) { return CreateClassProxy(classToProxy, additionalInterfacesToProxy, options, null, interceptors); @@ -1438,9 +1434,9 @@ public object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToP /// This method uses implementation to generate a proxy type. /// As such caller should expect any type of exception that given implementation may throw. /// - public virtual object CreateClassProxy(Type classToProxy, Type[] additionalInterfacesToProxy, + public virtual object CreateClassProxy(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options, - object[] constructorArguments, params IInterceptor[] interceptors) + object?[]? constructorArguments, params IInterceptor[] interceptors) { if (classToProxy == null) { @@ -1469,12 +1465,12 @@ public virtual object CreateClassProxy(Type classToProxy, Type[] additionalInter return CreateClassProxyInstance(proxyType, arguments, classToProxy, constructorArguments); } - protected object CreateClassProxyInstance(Type proxyType, List proxyArguments, Type classToProxy, - object[] constructorArguments) + protected object CreateClassProxyInstance(Type proxyType, List proxyArguments, Type classToProxy, + object?[]? constructorArguments) { try { - return Activator.CreateInstance(proxyType, proxyArguments.ToArray()); + return Activator.CreateInstance(proxyType, proxyArguments.ToArray())!; } catch (MissingMethodException ex) { @@ -1509,7 +1505,7 @@ protected void CheckNotGenericTypeDefinition(Type type, string argumentName) } } - protected void CheckNotGenericTypeDefinitions(IEnumerable types, string argumentName) + protected void CheckNotGenericTypeDefinitions(IEnumerable? types, string argumentName) { if (types == null) { @@ -1521,10 +1517,10 @@ protected void CheckNotGenericTypeDefinitions(IEnumerable types, string ar } } - protected List BuildArgumentListForClassProxyWithTarget(object target, ProxyGenerationOptions options, - IInterceptor[] interceptors) + protected List BuildArgumentListForClassProxyWithTarget(object? target, ProxyGenerationOptions options, + IInterceptor[] interceptors) { - var arguments = new List(); + var arguments = new List(); arguments.Add(target); arguments.AddRange(options.MixinData.Mixins); arguments.Add(interceptors); @@ -1535,9 +1531,9 @@ protected List BuildArgumentListForClassProxyWithTarget(object target, P return arguments; } - protected List BuildArgumentListForClassProxy(ProxyGenerationOptions options, IInterceptor[] interceptors) + protected List BuildArgumentListForClassProxy(ProxyGenerationOptions options, IInterceptor[] interceptors) { - var arguments = new List(options.MixinData.Mixins) { interceptors }; + var arguments = new List(options.MixinData.Mixins) { interceptors }; if (options.Selector != null) { arguments.Add(options.Selector); @@ -1553,7 +1549,7 @@ protected List BuildArgumentListForClassProxy(ProxyGenerationOptions opt /// The interfaces that proxy type should implement. /// The options for proxy generation process. /// of proxy. - protected Type CreateClassProxyType(Type classToProxy, Type[] additionalInterfacesToProxy, + protected Type CreateClassProxyType(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { // create proxy @@ -1570,7 +1566,7 @@ protected Type CreateClassProxyType(Type classToProxy, Type[] additionalInterfac /// Actual type that the proxy type will encompass. /// The options for proxy generation process. /// of proxy. - protected Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + protected Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, Type targetType, ProxyGenerationOptions options) { @@ -1588,7 +1584,7 @@ protected Type CreateInterfaceProxyTypeWithTarget(Type interfaceToProxy, Type[] /// The additional interfaces proxy type should implement. /// The options for proxy generation process. /// of proxy. - protected Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + protected Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { // create proxy @@ -1604,14 +1600,14 @@ protected Type CreateInterfaceProxyTypeWithTargetInterface(Type interfaceToProxy /// The additional interfaces proxy type should implement. /// The options for proxy generation process. /// of proxy. - protected Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[] additionalInterfacesToProxy, + protected Type CreateInterfaceProxyTypeWithoutTarget(Type interfaceToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { // create proxy return ProxyBuilder.CreateInterfaceProxyTypeWithoutTarget(interfaceToProxy, additionalInterfacesToProxy, options); } - protected Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[] additionalInterfacesToProxy, + protected Type CreateClassProxyTypeWithTarget(Type classToProxy, Type[]? additionalInterfacesToProxy, ProxyGenerationOptions options) { // create proxy diff --git a/src/Castle.Core/DynamicProxy/ProxyUtil.cs b/src/Castle.Core/DynamicProxy/ProxyUtil.cs index 780f7ca019..5adc871fb4 100644 --- a/src/Castle.Core/DynamicProxy/ProxyUtil.cs +++ b/src/Castle.Core/DynamicProxy/ProxyUtil.cs @@ -12,10 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System; using System.Collections.Generic; + using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; @@ -79,11 +82,11 @@ public static Delegate CreateDelegateToMixin(object proxy, Type delegateType) } } - public static object GetUnproxiedInstance(object instance) + public static object? GetUnproxiedInstance(object instance) { if (instance is IProxyTargetAccessor accessor) { - instance = accessor.DynProxyGetTarget(); + return accessor.DynProxyGetTarget(); } return instance; @@ -98,7 +101,7 @@ public static Type GetUnproxiedType(object instance) { if (ReferenceEquals(target, instance)) { - return instance.GetType().BaseType; + return instance.GetType().BaseType!; } instance = target; @@ -108,7 +111,7 @@ public static Type GetUnproxiedType(object instance) return instance.GetType(); } - public static bool IsProxy(object instance) + public static bool IsProxy(object? instance) { return instance is IProxyTargetAccessor; } @@ -124,7 +127,7 @@ public static bool IsProxyType(Type type) /// true if the method is accessible to DynamicProxy, false otherwise. public static bool IsAccessible(MethodBase method) { - return IsAccessibleMethod(method) && IsAccessibleType(method.DeclaringType); + return IsAccessibleMethod(method) && IsAccessibleType(method.DeclaringType!); } /// @@ -132,7 +135,7 @@ public static bool IsAccessible(MethodBase method) /// The method to check. /// If the method is accessible to DynamicProxy, null; otherwise, an explanation of why the method is not accessible. /// true if the method is accessible to DynamicProxy, false otherwise. - public static bool IsAccessible(MethodBase method, out string message) + public static bool IsAccessible(MethodBase method, [NotNullWhen(false)] out string? message) { if (IsAccessible(method)) { @@ -198,7 +201,7 @@ internal static bool IsAccessibleMethod(MethodBase method) { case MethodAttributes.Assembly: case MethodAttributes.FamANDAssem: - return AreInternalsVisibleToDynamicProxy(method.DeclaringType.Assembly); + return AreInternalsVisibleToDynamicProxy(method.DeclaringType!.Assembly); case MethodAttributes.Family: case MethodAttributes.FamORAssem: @@ -224,7 +227,7 @@ internal static bool IsInternal(MethodBase method) private static string CreateMessageForInaccessibleMethod(MethodBase inaccessibleMethod) { - var containingType = inaccessibleMethod.DeclaringType; + var containingType = inaccessibleMethod.DeclaringType!; var targetAssembly = containingType.Assembly; var messageFormat = "Can not create proxy for method {0} because it or its declaring type is not accessible. "; diff --git a/src/Castle.Core/DynamicProxy/StandardInterceptor.cs b/src/Castle.Core/DynamicProxy/StandardInterceptor.cs index 05163c164c..e7dc17c3b4 100644 --- a/src/Castle.Core/DynamicProxy/StandardInterceptor.cs +++ b/src/Castle.Core/DynamicProxy/StandardInterceptor.cs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#nullable enable + namespace Castle.DynamicProxy { using System;