当前位置: 首页>>代码示例>>C#>>正文


C# TypeNode.GetRuntimeType方法代码示例

本文整理汇总了C#中TypeNode.GetRuntimeType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeNode.GetRuntimeType方法的具体用法?C# TypeNode.GetRuntimeType怎么用?C# TypeNode.GetRuntimeType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeNode的用法示例。


在下文中一共展示了TypeNode.GetRuntimeType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();

            if ( IsTestFixture( runtimeType ) )
            {
                string ignoreReason = Reflect.GetIgnoreReason( runtimeType );
                if ( ignoreReason.Trim().Length == 0 )
                {
                    Resolution resolution = GetNamedResolution( "TestFixture", type.Name.Name );
                    Problem problem = new Problem( resolution );
                    base.Problems.Add( problem );
                }

                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods( BindingFlags.Instance | BindingFlags.Public );
                foreach( MethodInfo method in methods )
                {
                    string methodIgnoreReason = Reflect.GetIgnoreReason( method );
                    if ( methodIgnoreReason.Trim().Length == 0 )
                    {
                        string[] parameters = new string[] { type.Name.Name, method.Name };
                        Resolution resolution = GetNamedResolution( "TestCase", parameters );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:33,代码来源:IgnoreReasonShouldNotBeEmptyRule.cs

示例2: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods( BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly );

                // Note that if an method with an invalid signature is marked as a setup method, then
                // it will be considered as not marked and hence setupMethod will be null.
                // Same applies for tearDownMethod.
                System.Reflection.MethodInfo setupMethod = Reflect.GetSetUpMethod( runtimeType );
                System.Reflection.MethodInfo tearDownMethod = Reflect.GetTearDownMethod( runtimeType );
                System.Reflection.MethodInfo fixtureSetupMethod = Reflect.GetFixtureSetUpMethod( runtimeType );
                System.Reflection.MethodInfo fixtureTearDownMethod = Reflect.GetFixtureTearDownMethod( runtimeType );

                foreach( System.Reflection.MethodInfo methodInfo in methods )
                {
                    if ( !IsTestCaseMethod( methodInfo ) &&
                         ( methodInfo != setupMethod ) &&
                         ( methodInfo != tearDownMethod ) &&
                         ( methodInfo != fixtureSetupMethod ) &&
                         ( methodInfo != fixtureTearDownMethod ) )
                    {
                        Resolution resolution = GetResolution( methodInfo.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:35,代码来源:TestFixturesPublicMethodsShouldBeMarkedRule.cs

示例3: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();

            if ( IsTestFixture( runtimeType ) )
            {
                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods( BindingFlags.Instance | BindingFlags.Public );

                foreach( MethodInfo method in methods )
                {
                    if ( !Reflect.HasTestAttribute( method ) &&
                         ( Reflect.HasExpectedExceptionAttribute( method ) ||
                           Reflect.HasIgnoreAttribute( method ) ||
                           Reflect.HasCategoryAttribute( method ) ||
                           Reflect.HasExplicitAttribute( method )
                         )
                       )
                    {
                        Resolution resolution = GetResolution( method.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:30,代码来源:AttributeShouldOnlyMarkTestCasesRule.cs

示例4: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods();

                foreach( System.Reflection.MethodInfo methodInfo in methods )
                {
                    // if method starts with "test" and is not marked as [Test],
                    // then an explicit [Test] should be added since NUnit will
                    // treat it as a test case.
                    if ( IsTestCaseMethod( methodInfo ) && !Reflect.HasTestAttribute( methodInfo ) )
                    {
                        Resolution resolution = GetResolution( methodInfo.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:26,代码来源:TestCasesShouldBeMarkedWithTestCaseAttributeRule.cs

示例5: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                PropertyInfo[] properties;

                // check for instance public properties
                properties = runtimeType.GetProperties( BindingFlags.Instance | BindingFlags.Public );
                foreach( PropertyInfo instanceProperty in properties )
                {
                    Resolution resolution = GetResolution( instanceProperty.DeclaringType.Name, instanceProperty.Name );
                    Problem problem = new Problem( resolution );
                    base.Problems.Add( problem );
                }

                // check for static public properties, whether declared in the class
                // or one of its base classes.
                properties = runtimeType.GetProperties( BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy );
                foreach( PropertyInfo staticProperty in properties )
                {
                    Resolution resolution = GetResolution( staticProperty.DeclaringType.Name, staticProperty.Name );
                    Problem problem = new Problem( resolution );
                    base.Problems.Add( problem );
                }
            }

            if ( base.Problems.Count > 0 )
                return base.Problems;

            return base.Check (type);
        }
开发者ID:BackupTheBerlios,项目名称:fxcop4nunit-svn,代码行数:32,代码来源:TestFixturesShouldNotContainPublicPropertiesRule.cs

示例6: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                // if more than one setup, trigger error.
                if ( GetTestSetupMethodsCount( runtimeType ) > 1 )
                {
                    Resolution resolution = GetNamedResolution( "SetUp", type.Name.Name );
                    Problem problem = new Problem( resolution );
                    base.Problems.Add( problem );
                    return base.Problems;
                }

                // if more than one setup, trigger error.
                if ( GetFixtureSetupMethodsCount( runtimeType ) > 1 )
                {
                    Resolution resolution = GetNamedResolution( "TestFixtureSetUp", type.Name.Name );
                    Problem problem = new Problem( resolution );
                    base.Problems.Add( problem );
                    return base.Problems;
                }
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:26,代码来源:TestFixturesShouldHaveSingleSetupMethodRule.cs

示例7: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) && !runtimeType.IsAbstract && type.IsVisibleOutsideAssembly )
            {
                MemberList constructors = type.GetConstructors();

                for ( int i = 0; i < constructors.Length; ++i )
                {
                    Member constructor = constructors[i];

                    // only examine non-static constructors
                    Microsoft.Cci.InstanceInitializer instanceConstructor =
                        constructor as Microsoft.Cci.InstanceInitializer;

                    if ( instanceConstructor == null )
                        continue;

                    // trigger errors for non-default constructors.
                    if ( ( instanceConstructor.Parameters.Length != 0 ) &&
                         ( !instanceConstructor.IsPrivate ) )
                    {
                        Resolution resolution = GetResolution( runtimeType.Name );
                        Problem problem = new Problem( resolution );
                        base.Problems.Add( problem );
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:34,代码来源:TestFixturesShouldOnlyContainDefaultConstructorsRule.cs

示例8: Check

        public override ProblemCollection Check(TypeNode type)
        {
            if ( IsTestFixture( type.GetRuntimeType() ) &&
                 type.IsAbstract )
            {
                Resolution resolution = GetResolution( type.Name.Name );
                Problem problem = new Problem( resolution );
                base.Problems.Add( problem );
                return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:BackupTheBerlios,项目名称:fxcop4nunit-svn,代码行数:13,代码来源:TestFixturesShouldNotBeAbstractRule.cs

示例9: Check

        public override ProblemCollection Check(TypeNode type)
        {
            if ( IsTestFixture( type.GetRuntimeType() ) &&
                !type.IsAbstract && // abstract is handled by another rule
                type.IsVisibleOutsideAssembly && // if not visible, another rule will be triggered.
                !type.IsSealed )
            {
                Resolution resolution = GetResolution( type.Name.Name );
                Problem problem = new Problem( resolution );
                base.Problems.Add( problem );
                return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:15,代码来源:TestFixturesShouldBeSealedRule.cs

示例10: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();
            if ( IsTestFixture( runtimeType ) )
            {
                System.Reflection.MethodInfo[] methods = runtimeType.GetMethods();

                foreach( System.Reflection.MethodInfo methodInfo in methods )
                {
                    if ( IsNUnitMethod( methodInfo ) )
                    {
                        if ( methodInfo.GetParameters().Length > 0 )
                        {
                            Resolution resolution = GetNamedResolution( "Parameters", methodInfo.Name );
                            Problem problem = new Problem( resolution );
                            base.Problems.Add( problem );
                        }

                        if ( methodInfo.ReturnType != typeof(void) )
                        {
                            Resolution resolution = GetNamedResolution( "ReturnType", methodInfo.Name );
                            Problem problem = new Problem( resolution );
                            base.Problems.Add( problem );
                        }

                        if ( methodInfo.IsAbstract )
                        {
                            Resolution resolution = GetNamedResolution( "Abstract", methodInfo.Name );
                            Problem problem = new Problem( resolution );
                            base.Problems.Add( problem );
                        }

                        if ( methodInfo.IsStatic )
                        {
                            Resolution resolution = GetNamedResolution( "Static", methodInfo.Name );
                            Problem problem = new Problem( resolution );
                            base.Problems.Add( problem );
                        }
                    }
                }

                if ( base.Problems.Count > 0 )
                    return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:BackupTheBerlios,项目名称:fxcop4nunit-svn,代码行数:47,代码来源:InvalidMethodSignatureRule.cs

示例11: Check

        public override ProblemCollection Check(TypeNode type)
        {
            Type runtimeType = type.GetRuntimeType();

            // runtimeType can be null for Microsoft.Cci types.
            if ( ( runtimeType != null ) && !IsTestFixture( runtimeType ) &&
                 ( Reflect.HasCategoryAttribute( runtimeType ) ||
                   Reflect.HasExplicitAttribute( runtimeType ) ||
                   Reflect.HasIgnoreAttribute( runtimeType )
                 )
               )
            {
                Resolution resolution = GetResolution( type.Name.Name );
                Problem problem = new Problem( resolution );
                base.Problems.Add( problem );
                return base.Problems;
            }

            return base.Check (type);
        }
开发者ID:vboctor,项目名称:FxCop4NUnit,代码行数:20,代码来源:AttributeShouldOnlyMarkTestFixturesRule.cs


注:本文中的TypeNode.GetRuntimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。