Design Warnings


Visual Studio Team System
Members should not expose certain concrete types

TypeName

MembersShouldNotExposeCertainConcreteTypes

CheckId

CA1059

Category

Microsoft.Design

Breaking Change

Breaking

Cause

An externally visible member is a certain concrete type or exposes certain concrete types through one of its parameters or return value. Currently, this rule reports exposure of the following concrete types:

Rule Description

A concrete type is a type that has a complete implementation and therefore can be instantiated. To allow widespread use of the member, replace the concrete type with the suggested interface. This allows the member to accept any type that implements the interface or be used where a type that implements the interface is expected.

The following table lists the targeted concrete types and their suggested replacements.

Concrete type Replacement

XmlNode

System.Xml.Xpath.IXPathNavigable.

Using the interface decouples the member from a specific implementation of an XML data source.

How to Fix Violations

To fix a violation of this rule, change the concrete type to the suggested interface.

When to Exclude Warnings

It is safe to exclude a message from this rule if the specific functionality provided by the concrete type is required.

Related Rules

Consider passing base types as parameters

Tags :


Community Content

Azbola
System.Xml.XPath.IXPathNavigable not System.Xml.Xpath.IXPathNavigable

I think the replacement is supposed to read:

System.Xml.XPath.IXPathNavigable

and not

System.Xml.Xpath.IXPathNavigable

(note the capital 'P' in .XPath.)

 

Tags :

Anthony F Steele
Fake error
What this message basicaly says is: Instead of XmlDocument, XmlNode, XmlAttribute, you should use the type IXPathNavigable, since it's more general. Except when you can't do that, because you were using functionality which is specifically found on one of those classes, not IXPathNavigable. But under those circumstances the warning will show anyway, for reasons unknown or absent.

Page view tracker