private bool CalculateGenericPropertyMetrics(MemberNode node) { PropertyDeclarationSyntax syntaxNode = node.SyntaxNode as PropertyDeclarationSyntax; PropertyDeclarationSyntax propertyDeclarationSyntax = syntaxNode; if (syntaxNode != null) { bool flag = ((IEnumerable <SyntaxToken>)propertyDeclarationSyntax.Modifiers).Any <SyntaxToken>((SyntaxToken x) => x.ValueText == "static"); if (MemberBodySelector.FindBody(node) == null) { switch (node.Kind) { case MemberKind.GetProperty: { this.metrics = (flag ? HalsteadMetrics.GenericStaticGetPropertyMetrics : HalsteadMetrics.GenericInstanceGetPropertyMetrics); return(true); } case MemberKind.SetProperty: { this.metrics = (flag ? HalsteadMetrics.GenericStaticSetPropertyMetrics : HalsteadMetrics.GenericInstanceSetPropertyMetrics); return(true); } } } } return(false); }
public int Calculate(MemberNode node) { BlockSyntax blockSyntax = MemberBodySelector.FindBody(node); BlockSyntax blockSyntax1 = blockSyntax; if (blockSyntax != null) { this.Visit(blockSyntax1); } return(this.counter); }
public int Calculate(MemberNode node) { BlockSyntax blockSyntax = MemberBodySelector.FindBody(node); BlockSyntax blockSyntax1 = blockSyntax; if (blockSyntax != null) { this.Visit(blockSyntax1); } this.CalculateConstructorStatements(node); this.CalculateCompilerGeneratedPropertyStatements(node); return(this.counter); }
public int Calculate(MemberNode node) { BlockSyntax blockSyntax = MemberBodySelector.FindBody(node); BlockSyntax blockSyntax1 = blockSyntax; if (blockSyntax != null) { this.Visit(blockSyntax1); } int num = CyclomaticComplexityAnalyzer.CalculateLogicalComplexity(node); return(checked (this.counter + num)); }
public IHalsteadMetrics Calculate(MemberNode node) { BlockSyntax blockSyntax = MemberBodySelector.FindBody(node); BlockSyntax blockSyntax1 = blockSyntax; if (blockSyntax != null) { this.Visit(blockSyntax1); return(this.metrics); } if (!this.CalculateGenericPropertyMetrics(node)) { return(new HalsteadMetrics()); } return(this.metrics); }
private void CalculateCompilerGeneratedPropertyStatements(MemberNode node) { switch (node.Kind) { case MemberKind.GetProperty: case MemberKind.SetProperty: { if (MemberBodySelector.FindBody(node) == null) { StatementsAnalyzer statementsAnalyzer = this; statementsAnalyzer.counter = checked (statementsAnalyzer.counter + 1); } return; } default: { return; } } }
public static BlockSyntax FindBody(MemberNode node) { Func <SyntaxNode, BlockSyntax> func; Dictionary <MemberKind, Func <SyntaxNode, BlockSyntax> > memberKinds = new Dictionary <MemberKind, Func <SyntaxNode, BlockSyntax> >() { { MemberKind.Method, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => ((MethodDeclarationSyntax)x).Body) }, { MemberKind.Constructor, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => ((ConstructorDeclarationSyntax)x).Body) }, { MemberKind.Destructor, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => ((DestructorDeclarationSyntax)x).Body) }, { MemberKind.GetProperty, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => MemberBodySelector.GetPropertyAccessorBody((PropertyDeclarationSyntax)x, SyntaxKind.GetAccessorDeclaration)) }, { MemberKind.SetProperty, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => MemberBodySelector.GetPropertyAccessorBody((PropertyDeclarationSyntax)x, SyntaxKind.SetAccessorDeclaration)) }, { MemberKind.AddEventHandler, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => MemberBodySelector.GetEventAccessorBody((EventDeclarationSyntax)x, SyntaxKind.AddAccessorDeclaration)) }, { MemberKind.RemoveEventHandler, new Func <SyntaxNode, BlockSyntax>((SyntaxNode x) => MemberBodySelector.GetEventAccessorBody((EventDeclarationSyntax)x, SyntaxKind.RemoveAccessorDeclaration)) } }; if (memberKinds.TryGetValue(node.Kind, out func)) { BlockSyntax syntaxNode = func(node.SyntaxNode); BlockSyntax blockSyntax = syntaxNode; if (syntaxNode != null) { return(blockSyntax); } } return(null); }