2010-12-30 2 views
8

요즘 Visual Studio 2010 디버거가 [DebuggerStepThrough] 특성으로 표시된이 메서드로 점프하고 있음을 확인했습니다.DebuggerStepThrough가 무시됩니다.

Visual Studio 2010 stepping into a DebuggerStepThrough area

호출 스택은 다음과 같은 :

  1. Page.OnLoad는 [DebuggerStepThrough]로 표시된 클래스의 방법 IsSubclassOfGeneric를 호출합니다.
  2. IsSubclassOfGenericSystem.Linq.Enumerable.Any 연장 람다 식 전달 같이 GetHierarchy부른다.
  3. Visual Studio는 위와 같이 메서드를 단계별로 실행합니다.

난 그냥 아무 소용이, 아래와 같이 foreach 루프와 Linq에 전화를 교체 한 :이 방법은 꽤 자주 호출되기 때문에이 짜증의 비트,

Call to GetHierarchy

이며, 나는 그 속성이 왜 무시되고 있는지 이해하지 못한다.

답변

3

이 간단한 콘솔 응용 프로그램을 사용하여 표시된 줄에 중단 점을 넣고 디버거를 실행 한 후 첫 번째 중단 점에서 (F11) 단계를 누르십시오. 두 번째 중단 점이 없어야합니다. Otherwsie가 시각 스튜디오 설정/확장 일을 망칠 수도 있습니다.

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Diagnostics; 

namespace tmp { 
    class Program { 
     static void Main(string[] args) { 
      IEnumerable<Type> types = typeof(System.IO.IOException).GetHierarchy(typeof(System.Exception)); //break point here 
      int i = 0; 
     } 
    } 
    static class Ext { 
     //[DebuggerStepThrough] 
     //[DebuggerNonUserCode] 
     //[DebuggerStepperBoundary] 
     public static IEnumerable<Type> GetHierarchy(this Type type, Type limit) { 
      if (type == null) { //break point here 
       throw new Exception(); 
      } 
      do { 
       yield return type; 
       if (type == limit) { 
        yield break; 
       } 
      } while ((type = type.BaseType) != null); 
     } 

     [DebuggerStepThrough] 
     public static IEnumerable<Type> GetHierarchy2(this Type type, Type limit) { 
      if (type == null) { //break point here 
       throw new Exception(); 
      } 
      IList<Type> types = new List<Type>(); 
      do { 
       types.Add(type); 
       if (type == limit) { 
        break; 
       } 
      } while ((type = type.BaseType) != null); 
      return types; 
     } 
    } 
} 

EDIT 사실 내가 그것을 yield 문 함께 할 수있는 뭔가가 생각합니다. 목록 (GetHierarchy2)을 빌드하려고하면 DebuggerStepThrough 특성에 아무런 문제가 없습니다.

+0

그것은 확실히 그런 식으로 보입니다. 나는 솔직히 내가 이것을 더 일찍 알지 못한다는 것에 놀랐다. 내가 원하는 것을 얻을 수있는 다른 방법은 IEnumerable/IEnumerator 클래스를 명시 적으로 구현하는 것입니다.이 클래스는 성가신 일이지만 전체적으로 가치가있을 수 있습니다. –

0

릴리스 모드 바이너리를 디버깅 하시겠습니까? 컴파일시 컴파일러에 맞게 최적화되고 어쩌면 결정적 일 수 있으므로 단계를 수행 할 수 없습니다. 생성 된 IL을 살펴보고이 경우인지 확인하십시오.

+1

문제는 내가 원하지 않는 단계입니다. 나는 코드의 다른 측면에 초점을 맞추려고 노력하고 있는데, 이것은 계속해서 계속되고있다. –

관련 문제