Inheritance: System.Type
Example #1
0
 public static void RequireAll(
     [KeptAttributeAttribute(typeof(DynamicallyAccessedMembersAttribute))]
     [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)]
     System.Reflection.TypeDelegator t
     )
 {
 }
Example #2
0
        static void TestNoValue()
        {
            Type t             = null;
            Type noValue       = Type.GetTypeFromHandle(t.TypeHandle);
            var  typeDelegator = new System.Reflection.TypeDelegator(noValue);

            RequireAll(typeDelegator);
        }
	public void IsAssignableFrom ()
	{
		TypeDelegator td = new TypeDelegator (typeof (int));

		Assert.AreEqual (true, typeof (int).IsAssignableFrom (td));
		Assert.AreEqual (false, typeof (string).IsAssignableFrom (td));
		Assert.AreEqual (true, td.IsAssignableFrom (typeof (int)));
		Assert.AreEqual (false, td.IsAssignableFrom (typeof (string)));
    }
 public static string GetLogMessage(this Entity obj)
 {
     var tpe = obj.GetType();
     var val = string.Format("Entity name:{0};", tpe.Name);
     var info = new TypeDelegator(tpe);
     var props = info.GetProperties();
     props.ForEach(p => val += string.Format("{0}='{1}',", p.Name, tpe.InvokeMember(p.Name, BindingFlags.GetProperty, null, obj, null)));
     return val;
 }
Example #5
0
        static void TestDataFlowPropagation(
            [KeptAttributeAttribute(typeof(DynamicallyAccessedMembersAttribute))]
            [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)]
            Type typeWithPublicMethods = null)
        {
            var typeDelegator = new System.Reflection.TypeDelegator(typeWithPublicMethods);

            typeDelegator.RequiresPublicMethods();             // Should not warn
            typeDelegator.RequiresPublicFields();              // Should warn
        }
Example #6
0
        static void TestNullValue()
        {
            var typeDelegator = new System.Reflection.TypeDelegator(null);

            RequireAll(typeDelegator);
        }
Example #7
0
 static void TestTypeUsedWithDelegator()
 {
     _ = new System.Reflection.TypeDelegator(typeof(TypeUsedWithDelegator)).GetMethod("Method");
 }
        private void GuessType(object param, IEnumerable vals, object type)
        {
            if (param == null)
            {
                throw new ArgumentNullException("param", "Type can not be guessed for a null value."); // Use 'nameof' expression
            }

            if (type == null)
            {
                throw new ArgumentNullException(string.Format("Empty type '{0}'", type.GetType())); // Use string interpolation + possible NRE
            }

            if (vals == null)
            {
                throw new ArgumentNullException("vals"); // Use 'nameof' expression
            }

            if (!(param.ToString() == "check")) // Simplify negative equality expression
            {
                
            }

            if (type == typeof(int)) // Possible unintended reference comparison
            {
                // Source: http://stackoverflow.com/questions/9234009/c-sharp-type-comparison-type-equals-vs-operator
                Type type = new TypeDelegator(typeof(int)); // Merge variables
                Console.WriteLine(type.Equals(typeof(int))); // Check for reference equality instead
            }

            bool serializable = (type != null && type is Abstraction); // Merge sequential checks

        }
        public void GetRecordPropertyDictionary_IfTypeIsNotNull_ReturnDictionary()
        {
            //Arrange
            Type type = new TypeDelegator(typeof(RecWrapper));

            //Act
            // ReSharper disable ExpressionIsAlwaysNull
            var actual = MethodTestHelper.RunInstanceMethod<DbRecorderBase, Dictionary<string, PropertyInfo>>("GetRecordPropertyDictionary", _dbRecorderBase, new object[] { type });
            // ReSharper restore ExpressionIsAlwaysNull

            //Assert
            Assert.AreEqual(actual, GetRecordPropertyDictionary(type));
        }
Example #10
0
        static void TestDataFlowOfUnannotated(Type unknownType = null)
        {
            var typeDelegator = new System.Reflection.TypeDelegator(unknownType);

            unknownType.RequiresPublicMethods();
        }