在 <permission> 标签上

On the <permission> tag

我正在阅读有关 <permission> 标记的 C# 规范,语法如下:

<permission cref="member">description</permission> 

据说:

This tag allows the security accessibility of a member to be documented where cref="member" is the name of a member, while description is the description of the access to the member.

所以我可以争辩说这样的事情可能是有效的:

/// <permission cref="foo">foo is not accessible</permission>
private void foo() {}

然而在规范中有以下示例:

/// <permission cref="System.Security.PermissionSet">Everyone can 
/// access this method.</permission> 
public static void Test() { } 

如果 cref 是必须记录可访问性的成员,System.Security.PermissionSet 对它有何作用?

我真的不明白规格示例!!!

认为 旨在记录给定 method\class 的代码访问安全要求。例如:

/// <summary>
/// Do stuff
/// </summary>
/// <permission cref="PermissionSet">Caller should have full trust</permission>
[PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]        
public void DoStuff() {

}

这里我们要求完全信任权限集,我们在我们的方法文档中明确说明了这一点。还要考虑这个:

/// <summary>
///  Do stuff 2
/// </summary>
/// <permission cref="FileIOPermission">Caller should have unrestricted IO access</permission>
[FileIOPermission(SecurityAction.Demand, Unrestricted = true)]
public void DoStuff2() {

}

这里我们要求特定的 FileIOPermission(不是权限集),因此我们在文档中明确说明。

这当然不是为了记录成员的可访问性 (public\private) - 为什么要这样做呢?辅助功能是 function\class 定义的一部分,不需要记录。