Пример #1
0
        public override void VisitBlock(BlockSyntax node)
        {
            base.VisitBlock(node);
            IEnumerable <SyntaxToken> list = node.DescendantTokens(null, false).ToList <SyntaxToken>();
            IDictionary <SyntaxKind, IList <string> > syntaxKinds  = HalsteadAnalyzer.ParseTokens(list, HalsteadOperands.All);
            IDictionary <SyntaxKind, IList <string> > syntaxKinds1 = HalsteadAnalyzer.ParseTokens(list, HalsteadOperators.All);
            HalsteadMetrics halsteadMetric = new HalsteadMetrics()
            {
                NumOperands        = syntaxKinds.Values.SelectMany <IList <string>, string>((IList <string> x) => x).Count <string>(),
                NumUniqueOperands  = syntaxKinds.Values.SelectMany <IList <string>, string>((IList <string> x) => x).Distinct <string>().Count <string>(),
                NumOperators       = syntaxKinds1.Values.SelectMany <IList <string>, string>((IList <string> x) => x).Count <string>(),
                NumUniqueOperators = syntaxKinds1.Values.SelectMany <IList <string>, string>((IList <string> x) => x).Distinct <string>().Count <string>()
            };

            this.metrics = halsteadMetric;
        }
Пример #2
0
        static HalsteadMetrics()
        {
            HalsteadMetrics halsteadMetric = new HalsteadMetrics()
            {
                NumOperands        = 5,
                NumOperators       = 3,
                NumUniqueOperands  = 4,
                NumUniqueOperators = 3
            };

            HalsteadMetrics.GenericInstanceSetPropertyMetrics = halsteadMetric;
            HalsteadMetrics halsteadMetric1 = new HalsteadMetrics()
            {
                NumOperands        = 4,
                NumOperators       = 3,
                NumUniqueOperands  = 3,
                NumUniqueOperators = 3
            };

            HalsteadMetrics.GenericStaticSetPropertyMetrics = halsteadMetric1;
            HalsteadMetrics halsteadMetric2 = new HalsteadMetrics()
            {
                NumOperands        = 3,
                NumOperators       = 2,
                NumUniqueOperands  = 3,
                NumUniqueOperators = 2
            };

            HalsteadMetrics.GenericInstanceGetPropertyMetrics = halsteadMetric2;
            HalsteadMetrics halsteadMetric3 = new HalsteadMetrics()
            {
                NumOperands        = 2,
                NumOperators       = 1,
                NumUniqueOperands  = 2,
                NumUniqueOperators = 1
            };

            HalsteadMetrics.GenericStaticGetPropertyMetrics = halsteadMetric3;
        }