From 61188c6c596186112d800922a30f8cfbd8125af7 Mon Sep 17 00:00:00 2001 From: zzzprojects Date: Mon, 20 Jul 2015 07:43:18 -0400 Subject: [PATCH] Add: Object.Try, DirectoryInfo.CopyTo, [TypeInfo].GetSignature ADDED: DirectoryInfo.CopyTo // Copy the source directory to the destination directory ADDED: Try // Try an action and return the value or a bool ADDED: GetSignature // Get the signature from class, method, property, etc. FIXED: TypeInfo.GetDeclarations (Added support 'in' modifier, 'out' modifier, 'new', 'class') --- .../System.Object/Utility/Object.Try.cs | 169 ++++++++++++++++++ src/Z.Core/Z.Core.csproj | 1 + .../DirectoryInfo.CopyTo.cs | 77 ++++++++ src/Z.IO/Z.IO.csproj | 1 + .../FieldInfo.GetDeclaration.cs | 1 - .../GetDeclaration/TypeInfo.GetDeclaration.cs | 65 +++++-- .../ConstructorInfo.GetSignature.cs | 29 +++ .../GetSignature/EvenInfo.GetSignature.cs | 15 ++ .../GetSignature/FieldInfo.GetSignature.cs | 18 ++ .../GetSignature/MemberInfo.GetSignature.cs | 37 ++++ .../GetSignature/MethodInfo.GetSignature.cs | 44 +++++ .../ParameterInfo.GetSignature.cs | 57 ++++++ .../GetSignature/PropertyInfo.GetSignature.cs | 36 ++++ .../GetSignature/TypeInfo.GetSignature.cs | 55 ++++++ .../_Helper/TypeInfo.GetShortSignature.cs | 83 +++++++++ src/Z.Reflection/Z.Reflection.csproj | 9 + test/Z.Core.Test/System.Object/Object.Try.cs | 55 ++++++ .../StringBuilder.AppendJoin.cs | 4 +- .../StringBuilder.AppendLineIf.cs | 3 +- test/Z.Core.Test/Z.Core.Test.csproj | 1 + test/Z.Data.Test/Z.Data.Test.csproj | 12 -- .../DirectoryInfo.CopyTo.cs | 36 ++++ test/Z.IO.Test/Z.IO.Test.csproj | 1 + .../GetDeclaration/Method/GenericMethod.cs | 2 +- .../Constructor/GenericTypeConstructor.cs | 29 +++ .../InParameterModifierConstructor.cs | 28 +++ .../Constructor/InternalConstructor.cs | 29 +++ .../OptionalParameterConstructor.cs | 28 +++ .../OptionalParameterModifierConstructor.cs | 28 +++ .../Constructor/OutParameterConstructor.cs | 28 +++ .../OutParameterModifierConstructor.cs | 28 +++ .../Constructor/ParamsParameterConstructor.cs | 28 +++ .../Constructor/PrivateConstructor.cs | 29 +++ .../Constructor/PublicConstructor.cs | 29 +++ .../Constructor/RefParameterConstructor.cs | 28 +++ .../GetSignature/Field/ConstField.cs | 28 +++ .../GetSignature/Field/EventField.cs | 29 +++ .../GetSignature/Field/InternalField.cs | 29 +++ .../GetSignature/Field/PrivateField.cs | 29 +++ .../GetSignature/Field/ProtectedField.cs | 29 +++ .../Field/ProtectedInternalField.cs | 29 +++ .../GetSignature/Field/PublicField.cs | 29 +++ .../GetSignature/Field/ReadOnlyField.cs | 29 +++ .../GetSignature/Field/StaticField.cs | 29 +++ .../GetSignature/Field/VolatileField.cs | 29 +++ .../GetSignature/Method/AbstractMethod.cs | 28 +++ .../Method/ExtensionParameterMethod.cs | 28 +++ .../GetSignature/Method/GenericMethod.cs | 28 +++ .../GetSignature/Method/GenericTypeMethod.cs | 28 +++ .../Method/InParameterModifierMethod.cs | 28 +++ .../GetSignature/Method/InternalMethod.cs | 28 +++ .../Method/OptionalParameterMethod.cs | 28 +++ .../Method/OptionalParameterModifierMethod.cs | 28 +++ .../GetSignature/Method/OutParameterMethod.cs | 28 +++ .../Method/OutParameterModifierMethod.cs | 28 +++ .../GetSignature/Method/OverrideMethod.cs | 28 +++ .../Method/ParamsParameterMethod.cs | 28 +++ .../GetSignature/Method/PrivateMethod.cs | 28 +++ .../Method/ProtectedInternalMethod.cs | 28 +++ .../GetSignature/Method/ProtectedMethod.cs | 28 +++ .../GetSignature/Method/PublicMethod.cs | 28 +++ .../GetSignature/Method/RefParameterMethod.cs | 28 +++ .../GetSignature/Method/StaticMethod.cs | 28 +++ .../GetSignature/Method/VirtualMethod.cs | 28 +++ .../GetSignature/Property/AbstractProperty.cs | 28 +++ .../Property/GenericIndexerProperty.cs | 29 +++ .../GetSignature/Property/GenericProperty.cs | 28 +++ .../GetSignature/Property/GetterProperty.cs | 28 +++ .../GetSignature/Property/IndexerProperty.cs | 29 +++ .../GetSignature/Property/InternalProperty.cs | 28 +++ .../GetSignature/Property/OverrideProperty.cs | 28 +++ .../PrivateGetterPublicSetterProperty.cs | 28 +++ .../GetSignature/Property/PrivateProperty.cs | 28 +++ .../Property/ProtectedInternalProperty.cs | 28 +++ .../Property/ProtectedProperty.cs | 28 +++ .../PublicGetterPrivateSetterProperty.cs | 28 +++ .../GetSignature/Property/PublicProperty.cs | 28 +++ .../GetSignature/Property/SetterProperty.cs | 28 +++ .../GetSignature/Property/StaticProperty.cs | 28 +++ .../GetSignature/Property/VirtualProperty.cs | 28 +++ .../GetSignature/Type/AbstractClass.cs | 28 +++ .../GetSignature/Type/GenericClass.cs | 29 +++ .../Type/GenericClassWithWhereClause.cs | 28 +++ .../Type/IGenericInterfaceWithInParameter.cs | 28 +++ .../Type/IGenericInterfaceWithOutParameter.cs | 28 +++ .../GetSignature/Type/IPublicInterface.cs | 29 +++ .../GetSignature/Type/InheritedClass.cs | 29 +++ .../Type/InheritedClassAndInterface.cs | 28 +++ .../GetSignature/Type/InternalClass.cs | 28 +++ .../GetSignature/Type/PublicClass.cs | 29 +++ .../GetSignature/Type/StaticClass.cs | 28 +++ .../Z.Reflection.Test.csproj | 67 +++++++ 92 files changed, 2741 insertions(+), 32 deletions(-) create mode 100644 src/Z.Core/System.Object/Utility/Object.Try.cs create mode 100644 src/Z.IO/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs create mode 100644 src/Z.Reflection/GetSignature/ConstructorInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/EvenInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/FieldInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/MemberInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/MethodInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/ParameterInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/PropertyInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/TypeInfo.GetSignature.cs create mode 100644 src/Z.Reflection/GetSignature/_Helper/TypeInfo.GetShortSignature.cs create mode 100644 test/Z.Core.Test/System.Object/Object.Try.cs create mode 100644 test/Z.IO.Test/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/GenericTypeConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/InParameterModifierConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/InternalConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterModifierConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/OutParameterConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/OutParameterModifierConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/ParamsParameterConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/PrivateConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/PublicConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Constructor/RefParameterConstructor.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/ConstField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/EventField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/InternalField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/PrivateField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/ProtectedField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/ProtectedInternalField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/PublicField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/ReadOnlyField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/StaticField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Field/VolatileField.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/AbstractMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/ExtensionParameterMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/GenericMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/GenericTypeMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/InParameterModifierMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/InternalMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/OptionalParameterMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/OptionalParameterModifierMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/OutParameterMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/OutParameterModifierMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/OverrideMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/ParamsParameterMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/PrivateMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/ProtectedInternalMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/ProtectedMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/PublicMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/RefParameterMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/StaticMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Method/VirtualMethod.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/AbstractProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/GenericIndexerProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/GenericProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/GetterProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/IndexerProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/InternalProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/OverrideProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/PrivateGetterPublicSetterProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/PrivateProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/ProtectedInternalProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/ProtectedProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/PublicGetterPrivateSetterProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/PublicProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/SetterProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/StaticProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Property/VirtualProperty.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/AbstractClass.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/GenericClass.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/GenericClassWithWhereClause.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithInParameter.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithOutParameter.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/IPublicInterface.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/InheritedClass.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/InheritedClassAndInterface.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/InternalClass.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/PublicClass.cs create mode 100644 test/Z.Reflection.Test/GetSignature/Type/StaticClass.cs diff --git a/src/Z.Core/System.Object/Utility/Object.Try.cs b/src/Z.Core/System.Object/Utility/Object.Try.cs new file mode 100644 index 00000000..6ee4c879 --- /dev/null +++ b/src/Z.Core/System.Object/Utility/Object.Try.cs @@ -0,0 +1,169 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; + +public static partial class Extensions +{ + /// A TType extension method that tries. + /// Type of the type. + /// Type of the result. + /// The @this to act on. + /// The try function. + /// A TResult. + public static TResult Try(this TType @this, Func tryFunction) + { + try + { + return tryFunction(@this); + } + catch + { + return default(TResult); + } + } + + /// A TType extension method that tries. + /// Type of the type. + /// Type of the result. + /// The @this to act on. + /// The try function. + /// The catch value. + /// A TResult. + public static TResult Try(this TType @this, Func tryFunction, TResult catchValue) + { + try + { + return tryFunction(@this); + } + catch + { + return catchValue; + } + } + + /// A TType extension method that tries. + /// Type of the type. + /// Type of the result. + /// The @this to act on. + /// The try function. + /// The catch value factory. + /// A TResult. + public static TResult Try(this TType @this, Func tryFunction, Func catchValueFactory) + { + try + { + return tryFunction(@this); + } + catch + { + return catchValueFactory(@this); + } + } + + /// A TType extension method that tries. + /// Type of the type. + /// Type of the result. + /// The @this to act on. + /// The try function. + /// [out] The result. + /// A TResult. + public static bool Try(this TType @this, Func tryFunction, out TResult result) + { + try + { + result = tryFunction(@this); + return true; + } + catch + { + result = default(TResult); + return false; + } + } + + /// A TType extension method that tries. + /// Type of the type. + /// Type of the result. + /// The @this to act on. + /// The try function. + /// The catch value. + /// [out] The result. + /// A TResult. + public static bool Try(this TType @this, Func tryFunction, TResult catchValue, out TResult result) + { + try + { + result = tryFunction(@this); + return true; + } + catch + { + result = catchValue; + return false; + } + } + + /// A TType extension method that tries. + /// Type of the type. + /// Type of the result. + /// The @this to act on. + /// The try function. + /// The catch value factory. + /// [out] The result. + /// A TResult. + public static bool Try(this TType @this, Func tryFunction, Func catchValueFactory, out TResult result) + { + try + { + result = tryFunction(@this); + return true; + } + catch + { + result = catchValueFactory(@this); + return false; + } + } + + /// A TType extension method that attempts to action from the given data. + /// Type of the type. + /// The @this to act on. + /// The try action. + /// true if it succeeds, false if it fails. + public static bool Try(this TType @this, Action tryAction) + { + try + { + tryAction(@this); + return true; + } + catch + { + return false; + } + } + + /// A TType extension method that attempts to action from the given data. + /// Type of the type. + /// The @this to act on. + /// The try action. + /// The catch action. + /// true if it succeeds, false if it fails. + public static bool Try(this TType @this, Action tryAction, Action catchAction) + { + try + { + tryAction(@this); + return true; + } + catch + { + catchAction(@this); + return false; + } + } +} \ No newline at end of file diff --git a/src/Z.Core/Z.Core.csproj b/src/Z.Core/Z.Core.csproj index f9b6310a..d8b6a963 100644 --- a/src/Z.Core/Z.Core.csproj +++ b/src/Z.Core/Z.Core.csproj @@ -471,6 +471,7 @@ + diff --git a/src/Z.IO/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs b/src/Z.IO/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs new file mode 100644 index 00000000..21e09492 --- /dev/null +++ b/src/Z.IO/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs @@ -0,0 +1,77 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.IO; + +public static partial class Extensions +{ + /// A DirectoryInfo extension method that copies to. + /// The obj to act on. + /// Pathname of the destination directory. + public static void CopyTo(this DirectoryInfo obj, string destDirName) + { + obj.CopyTo(destDirName, "*.*", SearchOption.TopDirectoryOnly); + } + + /// A DirectoryInfo extension method that copies to. + /// The obj to act on. + /// Pathname of the destination directory. + /// A pattern specifying the search. + public static void CopyTo(this DirectoryInfo obj, string destDirName, string searchPattern) + { + obj.CopyTo(destDirName, searchPattern, SearchOption.TopDirectoryOnly); + } + + /// A DirectoryInfo extension method that copies to. + /// The obj to act on. + /// Pathname of the destination directory. + /// The search option. + public static void CopyTo(this DirectoryInfo obj, string destDirName, SearchOption searchOption) + { + obj.CopyTo(destDirName, "*.*", searchOption); + } + + /// A DirectoryInfo extension method that copies to. + /// Thrown when an exception error condition occurs. + /// The obj to act on. + /// Pathname of the destination directory. + /// A pattern specifying the search. + /// The search option. + public static void CopyTo(this DirectoryInfo obj, string destDirName, string searchPattern, SearchOption searchOption) + { + var files = obj.GetFiles(searchPattern, searchOption); + foreach (var file in files) + { + var outputFile = destDirName + file.FullName.Substring(obj.FullName.Length); + var directory = new FileInfo(outputFile).Directory; + + if (directory == null) + { + throw new Exception("The directory cannot be null."); + } + + if (!directory.Exists) + { + directory.Create(); + } + + file.CopyTo(outputFile); + } + + // Ensure empty dir are also copied + var directories = obj.GetDirectories(searchPattern, searchOption); + foreach (var directory in directories) + { + var outputDirectory = destDirName + directory.FullName.Substring(obj.FullName.Length); + var directoryInfo = new DirectoryInfo(outputDirectory); + if (!directoryInfo.Exists) + { + directoryInfo.Create(); + } + } + } +} \ No newline at end of file diff --git a/src/Z.IO/Z.IO.csproj b/src/Z.IO/Z.IO.csproj index 967fab49..6b834aa1 100644 --- a/src/Z.IO/Z.IO.csproj +++ b/src/Z.IO/Z.IO.csproj @@ -66,6 +66,7 @@ + diff --git a/src/Z.Reflection/GetDeclaration/FieldInfo.GetDeclaration.cs b/src/Z.Reflection/GetDeclaration/FieldInfo.GetDeclaration.cs index 8dd7b4de..ecf8a97c 100644 --- a/src/Z.Reflection/GetDeclaration/FieldInfo.GetDeclaration.cs +++ b/src/Z.Reflection/GetDeclaration/FieldInfo.GetDeclaration.cs @@ -18,7 +18,6 @@ public static partial class Extensions public static string GetDeclaraction(this FieldInfo @this) { // Example: [Visibility] [Modifier] [Type] [Name] [PostModifier]; - var sb = new StringBuilder(); // Variable diff --git a/src/Z.Reflection/GetDeclaration/TypeInfo.GetDeclaration.cs b/src/Z.Reflection/GetDeclaration/TypeInfo.GetDeclaration.cs index 62761633..bab4419a 100644 --- a/src/Z.Reflection/GetDeclaration/TypeInfo.GetDeclaration.cs +++ b/src/Z.Reflection/GetDeclaration/TypeInfo.GetDeclaration.cs @@ -5,6 +5,7 @@ // All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library using System; +using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; @@ -37,6 +38,8 @@ public static string GetDeclaraction(this Type @this) // Name sb.Append(@this.IsGenericType ? @this.Name.Substring(0, @this.Name.IndexOf('`')) : @this.Name); + List constraintType = new List(); + // GenericArguments if (@this.IsGenericType) { @@ -44,39 +47,71 @@ public static string GetDeclaraction(this Type @this) sb.Append("<"); sb.Append(string.Join(", ", arguments.Select(x => { - Type[] constraints = x.GetGenericParameterConstraints(); + GenericParameterAttributes sConstraints = x.GenericParameterAttributes; - foreach (Type constraint in constraints) + if (GenericParameterAttributes.None != (sConstraints & GenericParameterAttributes.Contravariant)) + { + sb.Append("in "); + } + if (GenericParameterAttributes.None != (sConstraints & GenericParameterAttributes.Covariant)) { - GenericParameterAttributes gpa = constraint.GenericParameterAttributes; - GenericParameterAttributes variance = gpa & GenericParameterAttributes.VarianceMask; + sb.Append("out "); + } - if (variance != GenericParameterAttributes.None) - { - sb.Append((variance & GenericParameterAttributes.Covariant) != 0 ? "in " : "out "); - } + List parameterConstraint = new List(); + + if (GenericParameterAttributes.None != (sConstraints & GenericParameterAttributes.ReferenceTypeConstraint)) + { + parameterConstraint.Add("class"); + } + + + if (GenericParameterAttributes.None != (sConstraints & GenericParameterAttributes.DefaultConstructorConstraint)) + { + parameterConstraint.Add("new()"); + } + + + if (parameterConstraint.Count > 0) + { + constraintType.Add(x.Name + " : " + string.Join(", " , parameterConstraint)); } return x.GetShortDeclaraction(); }))); sb.Append(">"); + + foreach (var argument in arguments) + { + GenericParameterAttributes sConstraints = argument.GenericParameterAttributes & GenericParameterAttributes.SpecialConstraintMask; + } } + List constaints = new List(); + // Inherited Class if (@this.BaseType != null && @this.BaseType != typeof (object)) { - hasInheritedClass = true; - - sb.Append(" : "); - sb.Append(@this.BaseType.GetShortDeclaraction()); + constaints.Add(@this.BaseType.GetShortDeclaraction()); } - + // Inherited Interface Type[] interfaces = @this.GetInterfaces(); if (interfaces.Length > 0) { - sb.Append(hasInheritedClass ? ", " : " : "); - sb.Append(string.Join(", ", interfaces.Select(x => x.Name))); + constaints.AddRange(interfaces.Select(x => x.Name)); + } + + if (constaints.Count > 0) + { + sb.Append(" : "); + sb.Append(string.Join(", ", constaints)); + } + + if (constraintType.Count > 0) + { + sb.Append(" where "); + sb.Append(string.Join(", ", constraintType)); } return sb.ToString(); diff --git a/src/Z.Reflection/GetSignature/ConstructorInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/ConstructorInfo.GetSignature.cs new file mode 100644 index 00000000..501c7a04 --- /dev/null +++ b/src/Z.Reflection/GetSignature/ConstructorInfo.GetSignature.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Linq; +using System.Reflection; +using System.Text; + +public static partial class Extensions +{ + public static string GetSignature(this ConstructorInfo @this) + { + // Example: [Name] [ x.GetSignature()))); + sb.Append(")"); + + return sb.ToString(); + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/EvenInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/EvenInfo.GetSignature.cs new file mode 100644 index 00000000..dff73ab4 --- /dev/null +++ b/src/Z.Reflection/GetSignature/EvenInfo.GetSignature.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; + +public static partial class Extensions +{ + public static string GetSignature(this EventInfo @this) + { + return null; + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/FieldInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/FieldInfo.GetSignature.cs new file mode 100644 index 00000000..9b82ae14 --- /dev/null +++ b/src/Z.Reflection/GetSignature/FieldInfo.GetSignature.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; + +public static partial class Extensions +{ + /// A FieldInfo extension method that gets a declaraction. + /// The @this to act on. + /// The declaraction. + public static string GetSignature(this FieldInfo @this) + { + return @this.Name; + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/MemberInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/MemberInfo.GetSignature.cs new file mode 100644 index 00000000..6f785d49 --- /dev/null +++ b/src/Z.Reflection/GetSignature/MemberInfo.GetSignature.cs @@ -0,0 +1,37 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; + +public static partial class Extensions +{ + /// A MemberInfo extension method that gets a declaraction. + /// The @this to act on. + /// The declaraction. + public static string GetSignature(this MemberInfo @this) + { + switch (@this.MemberType) + { + case MemberTypes.Field: + return ((FieldInfo) @this).GetSignature(); + case MemberTypes.Property: + return ((PropertyInfo) @this).GetSignature(); + case MemberTypes.Constructor: + return ((ConstructorInfo) @this).GetSignature(); + case MemberTypes.Method: + return ((MethodInfo) @this).GetSignature(); + case MemberTypes.TypeInfo: + return ((Type) @this).GetSignature(); + case MemberTypes.NestedType: + return ((Type) @this).GetSignature(); + case MemberTypes.Event: + return ((EventInfo) @this).GetSignature(); + default: + return null; + } + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/MethodInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/MethodInfo.GetSignature.cs new file mode 100644 index 00000000..d2a6765f --- /dev/null +++ b/src/Z.Reflection/GetSignature/MethodInfo.GetSignature.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Linq; +using System.Reflection; +using System.Text; + +public static partial class Extensions +{ + /// A MethodInfo extension method that gets a declaraction. + /// The @this to act on. + /// The declaraction. + public static string GetSignature(this MethodInfo @this) + { + // Example: [Visibility] [Modifier] [Type] [Name] [ x.GetShortSignature()))); + + sb.Append(">"); + } + + // Parameters + ParameterInfo[] parameters = @this.GetParameters(); + sb.Append("("); + sb.Append(string.Join(", ", parameters.Select(x => x.GetSignature()))); + sb.Append(")"); + + return sb.ToString(); + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/ParameterInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/ParameterInfo.GetSignature.cs new file mode 100644 index 00000000..acf6b399 --- /dev/null +++ b/src/Z.Reflection/GetSignature/ParameterInfo.GetSignature.cs @@ -0,0 +1,57 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Text; + +public static partial class Extensions +{ + /// A ParameterInfo extension method that gets a declaraction. + /// The @this to act on. + /// The declaraction. + public static string GetSignature(this ParameterInfo @this) + { + var sb = new StringBuilder(); + + @this.GetSignature(sb); + return sb.ToString(); + } + + internal static void GetSignature(this ParameterInfo @this, StringBuilder sb) + { + // retval attribute + + string typeName; + Type elementType = @this.ParameterType.GetElementType(); + + if (elementType != null) + { + typeName = @this.ParameterType.Name.Replace(elementType.Name, elementType.GetShortSignature()); + } + else + { + typeName = @this.ParameterType.GetShortSignature(); + } + + if (@this.IsOut) + { + if (typeName.Contains("&")) + { + typeName = typeName.Replace("&", ""); + sb.Append("out "); + } + } + else if (@this.ParameterType.IsByRef) + { + typeName = typeName.Replace("&", ""); + sb.Append("ref "); + } + sb.Append(typeName); + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/PropertyInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/PropertyInfo.GetSignature.cs new file mode 100644 index 00000000..02d8c4af --- /dev/null +++ b/src/Z.Reflection/GetSignature/PropertyInfo.GetSignature.cs @@ -0,0 +1,36 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Linq; +using System.Reflection; +using System.Text; + +public static partial class Extensions +{ + /// A PropertyInfo extension method that gets a declaraction. + /// The @this to act on. + /// The declaraction. + public static string GetSignature(this PropertyInfo @this) + { + // Example: [Name | Indexer[Type]] + + var indexerParameter = @this.GetIndexParameters(); + if (indexerParameter.Length == 0) + { + // Name + return @this.Name; + } + var sb = new StringBuilder(); + + // Indexer + sb.Append(@this.Name); + sb.Append("["); + sb.Append(string.Join(", ", indexerParameter.Select(x => x.ParameterType.GetShortSignature()))); + sb.Append("]"); + + return sb.ToString(); + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/TypeInfo.GetSignature.cs b/src/Z.Reflection/GetSignature/TypeInfo.GetSignature.cs new file mode 100644 index 00000000..c5d26bcd --- /dev/null +++ b/src/Z.Reflection/GetSignature/TypeInfo.GetSignature.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Linq; +using System.Reflection; +using System.Text; + +public static partial class Extensions +{ + /// A Type extension method that gets a declaraction. + /// The @this to act on. + /// The declaraction. + public static string GetSignature(this Type @this) + { + // Example: [Visibility] [Modifier] [Type] [Name] [] [:] [Inherited Class] [Inherited Interface] + var sb = new StringBuilder(); + + // Variable + bool hasInheritedClass = false; + + // Name + sb.Append(@this.IsGenericType ? @this.Name.Substring(0, @this.Name.IndexOf('`')) : @this.Name); + + // GenericArguments + if (@this.IsGenericType) + { + Type[] arguments = @this.GetGenericArguments(); + sb.Append("<"); + sb.Append(string.Join(", ", arguments.Select(x => + { + Type[] constraints = x.GetGenericParameterConstraints(); + + foreach (Type constraint in constraints) + { + GenericParameterAttributes gpa = constraint.GenericParameterAttributes; + GenericParameterAttributes variance = gpa & GenericParameterAttributes.VarianceMask; + + if (variance != GenericParameterAttributes.None) + { + sb.Append((variance & GenericParameterAttributes.Covariant) != 0 ? "in " : "out "); + } + } + + return x.GetShortDeclaraction(); + }))); + sb.Append(">"); + } + + return sb.ToString(); + } +} \ No newline at end of file diff --git a/src/Z.Reflection/GetSignature/_Helper/TypeInfo.GetShortSignature.cs b/src/Z.Reflection/GetSignature/_Helper/TypeInfo.GetShortSignature.cs new file mode 100644 index 00000000..551b2271 --- /dev/null +++ b/src/Z.Reflection/GetSignature/_Helper/TypeInfo.GetShortSignature.cs @@ -0,0 +1,83 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; + +public static partial class Extensions +{ + /// A Type extension method that gets short declaraction. + /// The @this to act on. + /// The short declaraction. + internal static string GetShortSignature(this Type @this) + { + if (@this == typeof (bool)) + { + return "bool"; + } + if (@this == typeof (byte)) + { + return "byte"; + } + if (@this == typeof (char)) + { + return "char"; + } + if (@this == typeof (decimal)) + { + return "decimal"; + } + if (@this == typeof (double)) + { + return "double"; + } + if (@this == typeof (Enum)) + { + return "enum"; + } + if (@this == typeof (float)) + { + return "float"; + } + if (@this == typeof (int)) + { + return "int"; + } + if (@this == typeof (long)) + { + return "long"; + } + if (@this == typeof (object)) + { + return "object"; + } + if (@this == typeof (sbyte)) + { + return "sbyte"; + } + if (@this == typeof (short)) + { + return "short"; + } + if (@this == typeof (string)) + { + return "string"; + } + if (@this == typeof (uint)) + { + return "uint"; + } + if (@this == typeof (ulong)) + { + return "ulong"; + } + if (@this == typeof (ushort)) + { + return "ushort"; + } + + return @this.Name; + } +} \ No newline at end of file diff --git a/src/Z.Reflection/Z.Reflection.csproj b/src/Z.Reflection/Z.Reflection.csproj index 76f0f971..5745bbe1 100644 --- a/src/Z.Reflection/Z.Reflection.csproj +++ b/src/Z.Reflection/Z.Reflection.csproj @@ -71,6 +71,15 @@ + + + + + + + + + diff --git a/test/Z.Core.Test/System.Object/Object.Try.cs b/test/Z.Core.Test/System.Object/Object.Try.cs new file mode 100644 index 00000000..6fe11631 --- /dev/null +++ b/test/Z.Core.Test/System.Object/Object.Try.cs @@ -0,0 +1,55 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Collections.Generic; +using System.Data; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Core.Test +{ + [TestClass] + public class System_Object_Try + { + [TestMethod] + public void Try() + { + // Type + var list = new List(); + list.Add(1); + + // Exemples + var result1 = list.Try(x => x[0]); + var result2 = list.Try(x => x[1]); + var result3 = list.Try(x => x[1], -1); + int result10; + int result11; + int result12; + var result7 = list.Try(x => x[0], out result10); + var result8 = list.Try(x => x[1], out result11); + var result9 = list.Try(x => x[1], -1, out result12); + var result4 = list.Try(x => x[1], ints => -2); + var result5 = list.Try(x => x.Add(2)); + var result6 = list.Try(x => { throw new Exception("exception!"); }, x => x.Add(3)); + + + // Unit Test + Assert.AreEqual(1, result1); + Assert.AreEqual(0, result2); + Assert.AreEqual(-1, result3); + Assert.AreEqual(-2, result4); + Assert.IsTrue(result5); + Assert.IsFalse(result6); + Assert.AreEqual(3, list.Count); + Assert.IsTrue(result7); + Assert.IsFalse(result8); + Assert.IsFalse(result9); + Assert.AreEqual(1, result10); + Assert.AreEqual(0, result11); + Assert.AreEqual(-1, result12); + } + } +} \ No newline at end of file diff --git a/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendJoin.cs b/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendJoin.cs index 3a57d3e3..50d20e67 100644 --- a/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendJoin.cs +++ b/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendJoin.cs @@ -14,7 +14,7 @@ namespace Z.Core.Test public class System_Text_StringBuilder_AppendJoin { [TestMethod] - public void AppendLineFormat() + public void AppendJoin() { var list = new List {"Fizz", "Buzz"}; @@ -23,7 +23,7 @@ public void AppendLineFormat() // Exemples - @this.AppendJoin(",", list); // return "Fizz,Buzz"; + @this.AppendJoin(",", list.ToArray()); // return "Fizz,Buzz"; // Unit Test Assert.AreEqual("Fizz,Buzz", @this.ToString()); diff --git a/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendLineIf.cs b/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendLineIf.cs index 86028203..69326258 100644 --- a/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendLineIf.cs +++ b/test/Z.Core.Test/System.Text.StringBuilder/StringBuilder.AppendLineIf.cs @@ -4,6 +4,7 @@ // Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 // All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library +using System; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -22,7 +23,7 @@ public void AppendLineIf() @this.AppendLineIf(x => x.Contains("F"), "Fizz", "Buzz"); // return "FizzBuzz"; // Unit Test - Assert.AreEqual("Fizz", @this.ToString()); + Assert.AreEqual("Fizz" + Environment.NewLine, @this.ToString()); } } } \ No newline at end of file diff --git a/test/Z.Core.Test/Z.Core.Test.csproj b/test/Z.Core.Test/Z.Core.Test.csproj index dad15747..7c026de2 100644 --- a/test/Z.Core.Test/Z.Core.Test.csproj +++ b/test/Z.Core.Test/Z.Core.Test.csproj @@ -61,6 +61,7 @@ + diff --git a/test/Z.Data.Test/Z.Data.Test.csproj b/test/Z.Data.Test/Z.Data.Test.csproj index 6351c5c8..302ae9c6 100644 --- a/test/Z.Data.Test/Z.Data.Test.csproj +++ b/test/Z.Data.Test/Z.Data.Test.csproj @@ -122,18 +122,6 @@ - - {0de7197d-d4e1-49e4-b9da-29ff24747a63} - Z.Data.MySql - - - {40cec7db-c8e6-4a24-8de7-9e0edf8708c6} - Z.Data.SQLite - - - {33c74c96-2394-4442-82ad-deb6c8df233f} - Z.Data.SqlServerCe - {6edebb64-2d4b-43cc-a94e-919b44e254a2} Z.Data diff --git a/test/Z.IO.Test/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs b/test/Z.IO.Test/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs new file mode 100644 index 00000000..ea69fc2d --- /dev/null +++ b/test/Z.IO.Test/System.IO.DirectoryInfo/DirectoryInfo.CopyTo.cs @@ -0,0 +1,36 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.IO; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.IO.Test +{ + [TestClass] + public class System_IO_DirectoryInfo_CopyTo + { + [TestMethod] + public void CopyTo() + { + // Type + var @this = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DirectoryInfo_CopyTo")); + var copyTo = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "DirectoryInfo_CopyTo2")); + + Directory.CreateDirectory(@this.FullName); + @this.CreateSubdirectory("FizzBuzz"); + var result1 = @this.GetDirectories().Length; + + // Exemples + @this.CopyTo(copyTo.FullName); + + // Unit Test + var result2 = copyTo.GetDirectories().Length; + Assert.AreEqual(1, result1); + Assert.AreEqual(1, result2); + } + } +} \ No newline at end of file diff --git a/test/Z.IO.Test/Z.IO.Test.csproj b/test/Z.IO.Test/Z.IO.Test.csproj index d48bbb05..0081a781 100644 --- a/test/Z.IO.Test/Z.IO.Test.csproj +++ b/test/Z.IO.Test/Z.IO.Test.csproj @@ -59,6 +59,7 @@ + diff --git a/test/Z.Reflection.Test/GetDeclaration/Method/GenericMethod.cs b/test/Z.Reflection.Test/GetDeclaration/Method/GenericMethod.cs index 52d6d3d0..732df240 100644 --- a/test/Z.Reflection.Test/GetDeclaration/Method/GenericMethod.cs +++ b/test/Z.Reflection.Test/GetDeclaration/Method/GenericMethod.cs @@ -10,7 +10,7 @@ namespace Z.Reflection.Test { [TestClass] - public class Method_GetDeclarationGenericMethod + public class Method_GetDeclaration_GenericMethod { [TestMethod] public void GetDeclaraction() diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/GenericTypeConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/GenericTypeConstructor.cs new file mode 100644 index 00000000..8c6a701e --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/GenericTypeConstructor.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_GenericTypeConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof (GenericTypeConstructorModel<>).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GenericTypeConstructorModel(T)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/InParameterModifierConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/InParameterModifierConstructor.cs new file mode 100644 index 00000000..5211ca9e --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/InParameterModifierConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_InParameterModifierConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(InParameterModifierConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InParameterModifierConstructorModel(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/InternalConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/InternalConstructor.cs new file mode 100644 index 00000000..4ea08328 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/InternalConstructor.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_InternalConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(InternalConstructorModel).GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InternalConstructorModel()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterConstructor.cs new file mode 100644 index 00000000..970cb906 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_OptionalParameterConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(OptionalParameterConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OptionalParameterConstructorModel(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterModifierConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterModifierConstructor.cs new file mode 100644 index 00000000..2a4fbfab --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/OptionalParameterModifierConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_OptionalParameterModifierConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(OptionalParameterModifierConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OptionalParameterModifierConstructorModel(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/OutParameterConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/OutParameterConstructor.cs new file mode 100644 index 00000000..9ee30244 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/OutParameterConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_OutParameterConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(OutParameterConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OutParameterConstructorModel(out int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/OutParameterModifierConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/OutParameterModifierConstructor.cs new file mode 100644 index 00000000..505c853d --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/OutParameterModifierConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_OutParameterModifierConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(OutParameterModifierConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OutParameterModifierConstructorModel(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/ParamsParameterConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/ParamsParameterConstructor.cs new file mode 100644 index 00000000..30d7ca2a --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/ParamsParameterConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_ParamsParameterConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(ParamsParameterConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ParamsParameterConstructorModel(int[])", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/PrivateConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/PrivateConstructor.cs new file mode 100644 index 00000000..56f8f2e3 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/PrivateConstructor.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_PrivateConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(PrivateConstructorModel).GetConstructors(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PrivateConstructorModel()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/PublicConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/PublicConstructor.cs new file mode 100644 index 00000000..a1e69f9d --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/PublicConstructor.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_PublicConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(PublicConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PublicConstructorModel()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Constructor/RefParameterConstructor.cs b/test/Z.Reflection.Test/GetSignature/Constructor/RefParameterConstructor.cs new file mode 100644 index 00000000..4a87c710 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Constructor/RefParameterConstructor.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Constructor_GetSignature_RefParameterConstructor + { + [TestMethod] + public void GetSignature() + { + // Type + ConstructorInfo @this = typeof(RefParameterConstructorModel).GetConstructors()[0]; + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("RefParameterConstructorModel(ref int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/ConstField.cs b/test/Z.Reflection.Test/GetSignature/Field/ConstField.cs new file mode 100644 index 00000000..4ef1841f --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/ConstField.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_ConstField + { + [TestMethod] + public void GetSignature() + { + // Type + FieldInfo @this = typeof (FieldModel).GetField("ConstField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ConstField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/EventField.cs b/test/Z.Reflection.Test/GetSignature/Field/EventField.cs new file mode 100644 index 00000000..3170a973 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/EventField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_EventField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("EventField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("EventField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/InternalField.cs b/test/Z.Reflection.Test/GetSignature/Field/InternalField.cs new file mode 100644 index 00000000..9179e58f --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/InternalField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_InternalField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("InternalField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InternalField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/PrivateField.cs b/test/Z.Reflection.Test/GetSignature/Field/PrivateField.cs new file mode 100644 index 00000000..b15c4f72 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/PrivateField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_PrivateField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("PrivateField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PrivateField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/ProtectedField.cs b/test/Z.Reflection.Test/GetSignature/Field/ProtectedField.cs new file mode 100644 index 00000000..50a5947d --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/ProtectedField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_ProtectedField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("ProtectedField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ProtectedField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/ProtectedInternalField.cs b/test/Z.Reflection.Test/GetSignature/Field/ProtectedInternalField.cs new file mode 100644 index 00000000..0722864e --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/ProtectedInternalField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_ProtectedInternalField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("ProtectedInternalField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ProtectedInternalField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/PublicField.cs b/test/Z.Reflection.Test/GetSignature/Field/PublicField.cs new file mode 100644 index 00000000..a79f06d7 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/PublicField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_PublicField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("PublicField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PublicField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/ReadOnlyField.cs b/test/Z.Reflection.Test/GetSignature/Field/ReadOnlyField.cs new file mode 100644 index 00000000..5a6bb75a --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/ReadOnlyField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_ReadOnlyField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("ReadOnlyField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ReadOnlyField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/StaticField.cs b/test/Z.Reflection.Test/GetSignature/Field/StaticField.cs new file mode 100644 index 00000000..86002fb9 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/StaticField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_StaticField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("StaticField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("StaticField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Field/VolatileField.cs b/test/Z.Reflection.Test/GetSignature/Field/VolatileField.cs new file mode 100644 index 00000000..1f91ced2 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Field/VolatileField.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Field_GetSignature_VolatileField + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(FieldModel).GetField("VolatileField", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("VolatileField", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/AbstractMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/AbstractMethod.cs new file mode 100644 index 00000000..d7158514 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/AbstractMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_AbstractMethod + { + [TestMethod] + public void GetSignature() + { + // Type + MethodInfo @this = typeof (AbstractMethodModel).GetMethod("AbstractMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("AbstractMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/ExtensionParameterMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/ExtensionParameterMethod.cs new file mode 100644 index 00000000..3519e00b --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/ExtensionParameterMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_ExtensionParameterMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(ExtensionMethodModel).GetMethod("ExtensionParameterMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ExtensionParameterMethod(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/GenericMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/GenericMethod.cs new file mode 100644 index 00000000..749f6d8b --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/GenericMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_GenericMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("GenericMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GenericMethod(T1, T2)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/GenericTypeMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/GenericTypeMethod.cs new file mode 100644 index 00000000..840116a9 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/GenericTypeMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_GenericTypeMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("GenericTypeMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GenericTypeMethod(T)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/InParameterModifierMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/InParameterModifierMethod.cs new file mode 100644 index 00000000..c9e99969 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/InParameterModifierMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_InParameterModifierMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("InParameterModifierMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InParameterModifierMethod(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/InternalMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/InternalMethod.cs new file mode 100644 index 00000000..9a6e3081 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/InternalMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_InternalMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("InternalMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InternalMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/OptionalParameterMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/OptionalParameterMethod.cs new file mode 100644 index 00000000..c275ea6d --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/OptionalParameterMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_OptionalParameterMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("OptionalParameterMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OptionalParameterMethod(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/OptionalParameterModifierMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/OptionalParameterModifierMethod.cs new file mode 100644 index 00000000..e1467617 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/OptionalParameterModifierMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_OptionalParameterModifierMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("OptionalParameterModifierMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OptionalParameterModifierMethod(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/OutParameterMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/OutParameterMethod.cs new file mode 100644 index 00000000..91ea2194 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/OutParameterMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_OutParameterMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("OutParameterMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OutParameterMethod(out int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/OutParameterModifierMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/OutParameterModifierMethod.cs new file mode 100644 index 00000000..1c132273 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/OutParameterModifierMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_OutParameterModifierMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("OutParameterModifierMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OutParameterModifierMethod(int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/OverrideMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/OverrideMethod.cs new file mode 100644 index 00000000..11a82e24 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/OverrideMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_OverrideMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("OverrideMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OverrideMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/ParamsParameterMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/ParamsParameterMethod.cs new file mode 100644 index 00000000..466d15da --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/ParamsParameterMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_ParamsParameterMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("ParamsParameterMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ParamsParameterMethod(int[])", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/PrivateMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/PrivateMethod.cs new file mode 100644 index 00000000..d5b690b8 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/PrivateMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_PrivateMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("PrivateMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PrivateMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/ProtectedInternalMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/ProtectedInternalMethod.cs new file mode 100644 index 00000000..3dbbb36c --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/ProtectedInternalMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_ProtectedInternalMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("ProtectedInternalMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ProtectedInternalMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/ProtectedMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/ProtectedMethod.cs new file mode 100644 index 00000000..71d3364f --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/ProtectedMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Protected_GetSignature_ProtectedMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("ProtectedMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ProtectedMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/PublicMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/PublicMethod.cs new file mode 100644 index 00000000..3f7ae6f9 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/PublicMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_PublicMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("PublicMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PublicMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/RefParameterMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/RefParameterMethod.cs new file mode 100644 index 00000000..4279bf52 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/RefParameterMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_RefParameterMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("RefParameterMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("RefParameterMethod(ref int)", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/StaticMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/StaticMethod.cs new file mode 100644 index 00000000..1c416380 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/StaticMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_StaticMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("StaticMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("StaticMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Method/VirtualMethod.cs b/test/Z.Reflection.Test/GetSignature/Method/VirtualMethod.cs new file mode 100644 index 00000000..72e5a9fe --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Method/VirtualMethod.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Method_GetSignature_VirtualMethod + { + [TestMethod] + public void GetSignature() + { + // Type + var @this = typeof(MethodModel<>).GetMethod("VirtualMethod", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("VirtualMethod()", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/AbstractProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/AbstractProperty.cs new file mode 100644 index 00000000..1fc90603 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/AbstractProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_AbstractProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(AbstractPropertyModel).GetProperty("AbstractProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("AbstractProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/GenericIndexerProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/GenericIndexerProperty.cs new file mode 100644 index 00000000..c4ea2b9b --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/GenericIndexerProperty.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Linq; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_GenericIndexerProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof (PropertyModel<>).GetProperties().First(x => x.Name == "Item" && x.GetIndexParameters().Length == 2); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("Item[T, int]", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/GenericProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/GenericProperty.cs new file mode 100644 index 00000000..4e385b28 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/GenericProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_GenericProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel<>).GetProperty("GenericProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GenericProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/GetterProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/GetterProperty.cs new file mode 100644 index 00000000..90bd9117 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/GetterProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_GetterProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("GetterProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GetterProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/IndexerProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/IndexerProperty.cs new file mode 100644 index 00000000..6ca77ab2 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/IndexerProperty.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Linq; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_IndexerProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof (PropertyModel).GetProperties().First(x => x.Name == "Item" && x.GetIndexParameters().Length == 3); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("Item[int, int, int]", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/InternalProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/InternalProperty.cs new file mode 100644 index 00000000..2ed6c494 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/InternalProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_InternalProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("InternalProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InternalProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/OverrideProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/OverrideProperty.cs new file mode 100644 index 00000000..9b891625 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/OverrideProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_OverrideProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("OverrideProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("OverrideProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/PrivateGetterPublicSetterProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/PrivateGetterPublicSetterProperty.cs new file mode 100644 index 00000000..1c0d77bf --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/PrivateGetterPublicSetterProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_PrivateGetterPublicSetterProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("PrivateGetterPublicSetterProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PrivateGetterPublicSetterProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/PrivateProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/PrivateProperty.cs new file mode 100644 index 00000000..7129fdd9 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/PrivateProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_PrivateProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("PrivateProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PrivateProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/ProtectedInternalProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/ProtectedInternalProperty.cs new file mode 100644 index 00000000..f019cf7a --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/ProtectedInternalProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_ProtectedInternalProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("ProtectedInternalProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ProtectedInternalProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/ProtectedProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/ProtectedProperty.cs new file mode 100644 index 00000000..a448a7c4 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/ProtectedProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_ProtectedProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("ProtectedProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("ProtectedProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/PublicGetterPrivateSetterProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/PublicGetterPrivateSetterProperty.cs new file mode 100644 index 00000000..23bd41fd --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/PublicGetterPrivateSetterProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_PublicGetterPrivateSetterProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("PublicGetterPrivateSetterProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PublicGetterPrivateSetterProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/PublicProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/PublicProperty.cs new file mode 100644 index 00000000..34049166 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/PublicProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_PublicProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("PublicProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PublicProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/SetterProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/SetterProperty.cs new file mode 100644 index 00000000..6ed96909 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/SetterProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_SetterProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("SetterProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("SetterProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/StaticProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/StaticProperty.cs new file mode 100644 index 00000000..09fa5cd3 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/StaticProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_StaticProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("StaticProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("StaticProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Property/VirtualProperty.cs b/test/Z.Reflection.Test/GetSignature/Property/VirtualProperty.cs new file mode 100644 index 00000000..0d0ac24a --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Property/VirtualProperty.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Property_GetSignature_VirtualProperty + { + [TestMethod] + public void GetSignature() + { + // Type + PropertyInfo @this = typeof(PropertyModel).GetProperty("VirtualProperty", BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("VirtualProperty", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/AbstractClass.cs b/test/Z.Reflection.Test/GetSignature/Type/AbstractClass.cs new file mode 100644 index 00000000..73126386 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/AbstractClass.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_AbstractClass + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (AbstractClass); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("AbstractClass", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/GenericClass.cs b/test/Z.Reflection.Test/GetSignature/Type/GenericClass.cs new file mode 100644 index 00000000..cc286455 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/GenericClass.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_GenericClass + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof(GenericClass<,>); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GenericClass", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/GenericClassWithWhereClause.cs b/test/Z.Reflection.Test/GetSignature/Type/GenericClassWithWhereClause.cs new file mode 100644 index 00000000..f3529b83 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/GenericClassWithWhereClause.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_GenericClassWithWhereClause + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (GenericClassWithWhereClause<>); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("GenericClassWithWhereClause", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithInParameter.cs b/test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithInParameter.cs new file mode 100644 index 00000000..3f002032 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithInParameter.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_IGenericInterfaceWithInParameter + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (IGenericInterfaceWithInParameter<>); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("IGenericInterfaceWithInParameter", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithOutParameter.cs b/test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithOutParameter.cs new file mode 100644 index 00000000..406aa63c --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/IGenericInterfaceWithOutParameter.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_IGenericInterfaceWithOutParameter + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (IGenericInterfaceWithOutParameter<>); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("IGenericInterfaceWithOutParameter", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/IPublicInterface.cs b/test/Z.Reflection.Test/GetSignature/Type/IPublicInterface.cs new file mode 100644 index 00000000..c74e1796 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/IPublicInterface.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_IPublicInterface + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (IPublicInterface); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("IPublicInterface", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/InheritedClass.cs b/test/Z.Reflection.Test/GetSignature/Type/InheritedClass.cs new file mode 100644 index 00000000..d0baa8d7 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/InheritedClass.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_InheritedClass + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof(InheritedClass); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InheritedClass", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/InheritedClassAndInterface.cs b/test/Z.Reflection.Test/GetSignature/Type/InheritedClassAndInterface.cs new file mode 100644 index 00000000..ecbdeac9 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/InheritedClassAndInterface.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_InheritedClassAndInterface + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof(InheritedClassAndInterface); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InheritedClassAndInterface", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/InternalClass.cs b/test/Z.Reflection.Test/GetSignature/Type/InternalClass.cs new file mode 100644 index 00000000..6569dcc2 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/InternalClass.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_InternalClass + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (InternalClass); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("InternalClass", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/PublicClass.cs b/test/Z.Reflection.Test/GetSignature/Type/PublicClass.cs new file mode 100644 index 00000000..06b839b4 --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/PublicClass.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using System.Reflection; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_PublicClass + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (PublicClass); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("PublicClass", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/GetSignature/Type/StaticClass.cs b/test/Z.Reflection.Test/GetSignature/Type/StaticClass.cs new file mode 100644 index 00000000..1a0080fd --- /dev/null +++ b/test/Z.Reflection.Test/GetSignature/Type/StaticClass.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2015 ZZZ Projects. All rights reserved +// Licensed under MIT License (MIT) (https://github.com/zzzprojects/Z.ExtensionMethods) +// Website: http://www.zzzprojects.com/ +// Feedback / Feature Requests / Issues : http://zzzprojects.uservoice.com/forums/283927 +// All ZZZ Projects products: Entity Framework Extensions / Bulk Operations / Extension Methods /Icon Library + +using System; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace Z.Reflection.Test +{ + [TestClass] + public class Type_GetSignature_StaticClass + { + [TestMethod] + public void GetSignature() + { + // Type + Type @this = typeof (StaticClass); + + // Exemples + string result = @this.GetSignature(); + + // Unit Test + Assert.AreEqual("StaticClass", result); + } + } +} \ No newline at end of file diff --git a/test/Z.Reflection.Test/Z.Reflection.Test.csproj b/test/Z.Reflection.Test/Z.Reflection.Test.csproj index 23f2097a..d249f56d 100644 --- a/test/Z.Reflection.Test/Z.Reflection.Test.csproj +++ b/test/Z.Reflection.Test/Z.Reflection.Test.csproj @@ -57,6 +57,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +