ArchiMetrics.CodeReview.Rules.Semantic.EmptyFinalizerRule.IsEmptyFinalizer C# (CSharp) Method

IsEmptyFinalizer() private method

private IsEmptyFinalizer ( Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.SemanticModel model ) : bool
node Microsoft.CodeAnalysis.SyntaxNode
model Microsoft.CodeAnalysis.SemanticModel
return bool
		private bool IsEmptyFinalizer(SyntaxNode node, SemanticModel model)
		{
			// NOTE: FxCop only checks if there is any method call within a given destructor to decide an empty finalizer.
			// Here in order to minimize false negatives, we conservatively treat it as non-empty finalizer if its body contains any statements.
			// But, still conditional methods like Debug.Fail() will be considered as being empty as FxCop currently does.
			return node.DescendantNodes().OfType<StatementSyntax>()
				.Where(n => !n.IsKind(SyntaxKind.Block) && !n.IsKind(SyntaxKind.EmptyStatement))
				.Select(exp => exp as ExpressionStatementSyntax)
				.All(method => method != null && HasConditionalAttribute(method.Expression, model));
		}