更新 : 2007 年 11 月
ValidElements プロパティは、ポインタが指し示すバッファまたは配列について、正常に読み取ることのできるバイト数を指定します。このプロパティは Pre 属性および Post 属性で使用でき、ポインタ型または配列データ型に対して使用できます。このプロパティの値は別のパラメータを含む式であり、このパラメータは実際の有効な要素数を指定します。
使用例
ValidElements プロパティの使用例を次のコードに示します。
// C
#include <CodeAnalysis\SourceAnnotations.h>
void f([SA_Pre(ValidElements="count") ] char *pc, size_t count);
// The keyword 'return' is used to indicate the return value,
// which in this case is the number of valid elements.
[returnvalue:SA_Post(MustCheck=SA_Yes)]int f([SA_Post(ValidElements="return")] char *pc);
// C++
#include <CodeAnalysis\SourceAnnotations.h>
using namespace vc_attributes;
void f([Pre(ValidElements="count") ] char *pc, size_t count);
// The keyword 'return' is used to indicate the return value,
// which in this case is the number of valid elements.
[returnvalue:Post(MustCheck=Yes)]int f([Post(ValidElements="return")] char *pc);