コード例 #1
0
        private void Extract(Context ctx, ContextStatistics stats)
        {
            var type = ctx.SST.EnclosingType;

            if (ctx.SST.IsPartialClass)
            {
                stats.NumPartial++;
            }
            ExtractTypeStats(stats, type);

            var th = ctx.TypeShape.TypeHierarchy;

            if (th.Implements.Count > 0 || th.Extends != null)
            {
                stats.NumTypeDeclExtendsOrImplements++;
            }

            foreach (var md in ctx.SST.Methods)
            {
                if (!_cf.ShouldProcessOrRegister(md.Name.RemoveGenerics()))
                {
                    continue;
                }

                stats.NumMethodDeclsTotal++;
                var overridden    = false;
                var overriddenAsm = false;
                foreach (var mh in ctx.TypeShape.MethodHierarchies)
                {
                    if (md.Name.Equals(mh.Element))
                    {
                        overridden = mh.Super != null || mh.First != null;

                        var isOverridingSuperAsm = mh.Super != null && !mh.Super.DeclaringType.Assembly.IsLocalProject;
                        var isOverridingFirstAsm = mh.First != null && !mh.First.DeclaringType.Assembly.IsLocalProject;
                        overriddenAsm = isOverridingSuperAsm || isOverridingFirstAsm;
                    }
                }
                if (overridden)
                {
                    stats.NumMethodDeclsOverrideOrImplement++;
                }
                if (overriddenAsm)
                {
                    stats.NumMethodDeclsOverrideOrImplementAsm++;
                    stats.UniqueMethodDeclsOverrideOrImplementAsm.Add(md.Name.RemoveGenerics());
                }
            }

            ctx.SST.Accept(new StatsCountVisitor(), stats);
            stats.EstimatedLinesOfCode += ctx.SST.Accept(new LinesOfCodeVisitor(), 0);
        }
コード例 #2
0
        public IContextStatistics Extract(IEnumerable <Context> contexts)
        {
            var stats = new ContextStatistics
            {
                NumSolutions = 1
            };

            foreach (var ctx in contexts)
            {
                if (_cf.ShouldProcessOrRegister(ctx.SST))
                {
                    Extract(ctx, stats);
                }
            }

            return(stats);
        }
コード例 #3
0
        private static void ExtractTypeStats(ContextStatistics stats, ITypeName type)
        {
            stats.UniqueTypeDecl.Add(type);

            if (type.IsNestedType)
            {
                stats.NumTypeDeclNested++;
            }
            else
            {
                stats.NumTypeDeclTopLevel++;
            }

            if (type.IsUnknown || type.IsPredefined || type.IsArray)
            {
                stats.NumUnusualType++;
            }
            else if (type.IsClassType)
            {
                stats.NumClasses++;
            }
            else if (type.IsInterfaceType)
            {
                stats.NumInterfaces++;
            }
            else if (type.IsDelegateType)
            {
                stats.NumDelegates++;
            }
            else if (type.IsStructType)
            {
                stats.NumStructs++;
            }
            else if (type.IsEnumType)
            {
                stats.NumEnums++;
            }
        }
コード例 #4
0
 protected bool Equals(ContextStatistics other)
 {
     return(NumRepositories == other.NumRepositories && NumUsers == other.NumUsers &&
            NumSolutions == other.NumSolutions && EstimatedLinesOfCode == other.EstimatedLinesOfCode &&
            NumTypeDeclTopLevel == other.NumTypeDeclTopLevel && NumTypeDeclNested == other.NumTypeDeclNested &&
            NumPartial == other.NumPartial && NumClasses == other.NumClasses &&
            NumInterfaces == other.NumInterfaces &&
            NumDelegates == other.NumDelegates && NumStructs == other.NumStructs && NumEnums == other.NumEnums &&
            NumUnusualType == other.NumUnusualType &&
            NumTypeDeclExtendsOrImplements == other.NumTypeDeclExtendsOrImplements &&
            NumMethodDeclsTotal == other.NumMethodDeclsTotal &&
            NumMethodDeclsOverrideOrImplement == other.NumMethodDeclsOverrideOrImplement &&
            NumMethodDeclsOverrideOrImplementAsm == other.NumMethodDeclsOverrideOrImplementAsm &&
            NumValidInvocations == other.NumValidInvocations &&
            NumUnknownInvocations == other.NumUnknownInvocations &&
            UniqueAssemblies.Equals(other.UniqueAssemblies) && NumAsmCalls == other.NumAsmCalls &&
            NumAsmDelegateCalls == other.NumAsmDelegateCalls && UniqueTypeDecl.Equals(other.UniqueTypeDecl) &&
            UniqueAsmMethods.Equals(other.UniqueAsmMethods) &&
            UniqueMethodDeclsOverrideOrImplementAsm.Equals(other.UniqueMethodDeclsOverrideOrImplementAsm) &&
            NumAsmFieldRead == other.NumAsmFieldRead && UniqueAsmFields.Equals(other.UniqueAsmFields) &&
            NumAsmPropertyRead == other.NumAsmPropertyRead &&
            UniqueAsmProperties.Equals(other.UniqueAsmProperties));
 }