성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] 그냥 RSS Reader 기능과 약간의 UI 편의성 때문에 사용...
[이종효] 오래된 소프트웨어는 보안 위협이 되기도 합니다. 혹시 어떤 기능...
[정성태] @Keystroke IEEE의 문서를 소개해 주시다니... +_...
[손민수 (Keystroke)] 괜히 듀얼채널 구성할 때 한번에 같은 제품 사라고 하는 것이 아...
[정성태] 전각(Full-width)/반각(Half-width) 기능을 토...
[정성태] Vector에 대한 내용은 없습니다. Vector가 닷넷 BCL...
[orion] 글 읽고 찾아보니 디자인 타임에는 InitializeCompon...
[orion] 연휴 전에 재현 프로젝트 올리자 생각해 놓고 여의치 않아서 못 ...
[정성태] 아래의 글에 정리했으니 참고하세요. C# - Typed D...
[정성태] 간단한 재현 프로젝트라도 있을까요? 저런 식으로 설명만 해...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>목록(List) 타입의 값을 디버깅 중 Watch 창에서 확인하는 방법</h1> <p> 간단한 예로, 다음과 같은 코드를 디버거로 구동해 BreakPoint를 찍어 list를 watch 창에서 확인하면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System; using System.Collections.Generic; class Program { static void Main(string[] args) { List<int> list = new List<int>(); for (int i = 0; i < 5; i ++) { list.Add(i); // 이 라인에 BreakPoint를 걸음. } } } </pre> <br /> 다음과 같이 "Value" 칼럼에는 Count만 나옵니다.<br /> <br /> <img alt='list_debug_helper_1.png' src='/SysWebRes/bbs/list_debug_helper_1.png' /><br /> <br /> 값을 보기 위해 "list" 이름의 왼쪽에 있는 화살표를 누르면 다음과 같이 펼쳐지긴 하는데요.<br /> <br /> <img alt='list_debug_helper_2.png' src='/SysWebRes/bbs/list_debug_helper_2.png' /><br /> <br /> 문제는, F10/F11 키를 눌러 디버깅을 진행하면 항목이 추가될 때마다 펼쳐놓은 것이 접히게 되어 값을 확인하려면 다시 Watch 창에서 왼쪽의 펼침 마크를 눌러줘야 합니다. 디버깅하다보면 이 작업이 여간 귀찮지 않은데요. 그냥 차라리 Value 칼럼에 값을 보여주면 좋겠는데... 애석하게도 방법이 없습니다.<br /> <br /> 얼핏, 비주얼 스튜디오에서 제공하는 Visualizer 확장을 이용해 해결할 수 있을 듯 싶지만,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > How to: Write a Visualizer ; <a target='tab' href='https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/how-to-write-a-visualizer'>https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2015/debugger/how-to-write-a-visualizer</a> Comprehensive list of Debugger Visualizers for Visual Studio ; <a target='tab' href='http://alexpinsker.blogspot.kr/2009/06/comprehensive-list-of-debugger.html'>http://alexpinsker.blogspot.kr/2009/06/comprehensive-list-of-debugger.html</a> </pre> <br /> 아쉽게도 디버거 비주얼라이저는 반드시 창을 띄워서 해결해야 하고, 게다가 모달(modal) 형식으로 뜨기 때문에 F10/F11 키를 눌러 디버깅을 진행하려면 다시 창을 닫아야 하는 불편함이 있습니다. 다음은 이에 대한 개선 요청입니다. (저도 투표했습니다. ^^)<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Make the debugging Visualizers non-modal windows ; <a target='tab' href='http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5711364-make-the-debugging-visualizers-non-modal-windows'>http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5711364-make-the-debugging-visualizers-non-modal-windows</a> </pre> <br /> <hr style='width: 50%' /><br /> <br /> 정식 해결책은 아니지만, 그래도 개인적으로 쓰고 있는 팁이 있다면 다음과 같은 식입니다. DEBUG 모드에서만 컴파일되도록 도우미 클래스를 하나 만들고,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System; using System.Collections.Generic; using System.Text; class Program { static void Main(string[] args) { List<int> list = new List<int>(); <span style='color: blue; font-weight: bold'>#if DEBUG ListDebugHelper<int> listLDH = new ListDebugHelper<int>(list, ", "); #endif</span> for (int i = 0; i < 5; i++) { list.Add(i); } } } #if DEBUG class ListDebugHelper<T> { IEnumerable<T> _list; string _split = string.Empty; public ListDebugHelper(IEnumerable<T> list) : this(list, string.Empty) { } public ListDebugHelper(IEnumerable<T> list, string split) { _list = list; _split = split; } public override string ToString() { StringBuilder sb = new StringBuilder(); foreach (var item in _list) { sb.Append(item); sb.Append(_split); } return sb.ToString(); } } #endif </pre> <br /> 그것의 인스턴스를 Watch 창에 등록해 두면 다음과 같이 Value 칼럼을 통해 직접 확인할 수 있습니다.<br /> <br /> <img alt='list_debug_helper_3.png' src='/SysWebRes/bbs/list_debug_helper_3.png' /><br /> <br /> 혹시 개인적으로 사용하고 있는 더 나은 팁이 있으시다면 덧글 공유 부탁드립니다. ^^<br /> <br /> (<a target='tab' href='http://www.sysnet.pe.kr/bbs/DownloadAttachment.aspx?fid=946&boardid=331301885'>첨부한 파일은 위의 예제를 테스트한 코드</a>입니다.)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1295
(왼쪽의 숫자를 입력해야 합니다.)