示例#1
0
        internal static string GetMethodDescription(this MethodInfo @this, SortedSet <string> namespaces, bool includeOverride,
                                                    RequiresExplicitInterfaceImplementation requiresExplicitInterfaceImplementation)
        {
            if (@this.IsGenericMethod)
            {
                @this = @this.GetGenericMethodDefinition();
            }

            @this.ReturnType.AddNamespaces(namespaces);

            var isOverride = includeOverride ? (@this.DeclaringType.IsClass ? "override " : string.Empty) : string.Empty;
            var returnType = @this.ReturnType == typeof(void) ?
                             "void" : $"{@this.ReturnType.GetFullName(namespaces, @this.ReturnParameter)}";

            var methodName  = @this.Name;
            var generics    = string.Empty;
            var constraints = string.Empty;

            if (@this.IsGenericMethodDefinition)
            {
                (generics, constraints) = @this.GetGenericArguments(namespaces);
                constraints             = constraints.Length == 0 ? string.Empty : $" {constraints}";
            }

            var parameters            = @this.GetParameters(namespaces);
            var explicitInterfaceName = requiresExplicitInterfaceImplementation == RequiresExplicitInterfaceImplementation.Yes ?
                                        $"{@this.DeclaringType.GetFullName(namespaces)}." : string.Empty;

            return($"{isOverride}{returnType} {explicitInterfaceName}{methodName}{generics}({parameters}){constraints}");
        }
 internal PropertyMockableResult(PropertyInfo value, RequiresExplicitInterfaceImplementation requiresExplicitInterfaceImplementation,
                                 PropertyAccessors accessors)
     : base(value, requiresExplicitInterfaceImplementation) =>
     this.Accessors = accessors;
示例#3
0
 internal MethodMockableResult(MethodInfo value, RequiresExplicitInterfaceImplementation requiresExplicitInterfaceImplementation,
                               RequiresIsNewImplementation requiresIsNewImplementation)
     : base(value, requiresExplicitInterfaceImplementation) =>
     this.RequiresNewImplementation = requiresIsNewImplementation;
示例#4
0
 internal MockableResult(T value, RequiresExplicitInterfaceImplementation requiresExplicitInterfaceImplementation) =>
 (this.Value, this.RequiresExplicitInterfaceImplementation) = (value, requiresExplicitInterfaceImplementation);
示例#5
0
		internal static string GetMethodDescription(this MethodInfo @this, SortedSet<string> namespaces, bool includeOverride,
			RequiresExplicitInterfaceImplementation requiresExplicitInterfaceImplementation)
		{
			if (@this.IsGenericMethod)
			{
				@this = @this.GetGenericMethodDefinition();
			}

			@this.ReturnType.AddNamespaces(namespaces);

			var isOverride = includeOverride ? (@this.DeclaringType.IsClass ? "override " : string.Empty) : string.Empty;
			var returnType = @this.ReturnType == typeof(void) ?
				"void" : $"{@this.ReturnType.GetFullName(namespaces)}";

			var methodName = @this.Name;
			var generics = string.Empty;
			var constraints = string.Empty;

			if (@this.IsGenericMethodDefinition)
			{
				var result = @this.GetGenericArguments(namespaces);
				generics = result.Arguments;
				constraints = result.Constraints.Length == 0 ? string.Empty : $" {result.Constraints}";
			}

			var parameters = @this.GetParameters(namespaces);
			var explicitInterfaceName = requiresExplicitInterfaceImplementation == RequiresExplicitInterfaceImplementation.Yes ?
				$"{@this.DeclaringType.GetFullName(namespaces)}." : string.Empty;

			return $"{isOverride}{returnType} {explicitInterfaceName}{methodName}{generics}({parameters}){constraints}";
		}