사용자 지정 FxCop 규칙을 통해 특정 메서드 (MessageBox.Show)에 대한 호출을 거부하려고합니다. 나는 FxCop 규칙을 사용자 정의 구현 (XML 파일, BaseIntrospectionRule 등 상속) 얻는 방법을 알고있다. 여기에 내 질문은 내가 "확인"메서드에 넣은 것입니다.사용자 지정 규칙을 통해 FxCop에서 특정 메서드에 대한 호출을 검색하는 방법 - 무엇을 넣을 지 검사 메서드
다음은 웹에서 많은 것을 파고 들기에 기초한 초기 초안입니다. 그러나 실제로 표시된 두 필드에 무엇이 채워지는지 궁금합니다. ?????.
이 솔루션이 존재하더라도 제대로 작동하는지 확신 할 수 없습니다. MessageBox에 대한 모든 호출을 수신하고 있습니다. 원하는 것을하고 있는지 확인하기위한 어리석은 증거는 무엇입니까?
public override ProblemCollection Check(Member member)
{
Method method = member as Method;
if (method == null)
{
return null;
}
MetadataCollection<Instruction>.Enumerator enumerator = method.Instructions.GetEnumerator();
while (enumerator.MoveNext())
{
Instruction current = enumerator.Current;
switch (current.OpCode)
{
case OpCode.Call:
case OpCode.Callvirt:
{
Method method3 = current.Value as Method;
if (method3 == **?????**)
{
Problem item = new Problem(base.GetResolution(**?????**), current);
base.Problems.Add(item);
}
break;
}
}
}
return base.Problems;
}
지침은 FxCop 규칙을 작성하는 '오래된 방법'입니다. 대신 방문 메소드를 사용하는 것이 더 쉽습니다. 나에 의해 작성된 사용자 정의 규칙은 string.ToString (다른 것들 중에서도) 호출을 조회합니다. https://fxcopcontrib.codeplex.com/SourceControl/changeset/view/7476#37972 – jessehouwing
맞춤 규칙에 대한 최고의 자습서는 다음과 같습니다. 여기에 있습니다 : http://www.binarycoder.net/fxcop/index.html – jessehouwing