성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
글쓰기
제목
이름
암호
전자우편
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'>Roslyn 맛보기 - C# Interactive (1)</h1> <p> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Roslyn 맛보기 (1) - <a target='tab' href='http://www.sysnet.pe.kr/2/0/1153'>C# 소스 코드를 스크립트 처럼 다루는 방법</a> Roslyn 맛보기 (2) - C# Interactive (1) Roslyn 맛보기 (3) - <a target='tab' href='http://www.sysnet.pe.kr/2/0/1155'>C# Interactive (2)</a> Roslyn 맛보기 (4) - <a target='tab' href='http://www.sysnet.pe.kr/2/0/1156'>Roslyn Services APIs를 이용한 Code Issue 및 Code Action 기능 소개</a> Roslyn 맛보기 (5) - <a target='tab' href='http://www.sysnet.pe.kr/2/0/1157'>Syntax Analysis (Roslyn Syntax API)</a> Roslyn 맛보기 (6) - <a target='tab' href='http://www.sysnet.pe.kr/2/0/1158'>Roslyn Symbol / Binding API</a> Roslyn 맛보기 (7) - <a target='tab' href='http://www.sysnet.pe.kr/2/0/1159'>SyntaxTree 조작</a> </pre> <br /> F# 공부하시는 분들은... "F# Interactive" 윈도우를 한번쯤 사용해 보셨을 텐데요. Roslyn이 나오면서, Roslyn 자체의 실습(?) 대상으로 만들어져 제공되는 "C# Interactive"가 새롭게 추가되었습니다. (아니면, C# 용 "Immediate Window"가 하나 생겼다고 보셔도 됩니다. ^^)<br /> <br /> Roslyn을 설치하면, Visual Studio에서 "View" / "Other Windows" / "C# Interactive Window" 메뉴가 생기는데, 실행하면 다음과 같은 창이 뜹니다.<br /> <br /> <img alt='csharp_interactive_1.png' src='/SysWebRes/bbs/csharp_interactive_1.png' /><br /> <br /> 여기에 입력할 수 있는 명령어는 크게 2가지 종류로 나뉩니다.<br /> <br /> <ul> <li>C# Interactive 명령어</li> <li>C# 코드</li> </ul> <br /> "C# Interactive"의 자체적인 명령어는 prompt에서 "# (Sharp)" 글자로 시작해서 명령을 내리면 됩니다. 아래는 '#help'로 구한 명령어 목록입니다.<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> <span style='color: blue; font-weight: bold'>cls</span> Clears the contents of the REPL editor window.<br /> <span style='color: blue; font-weight: bold'>help</span> Display help on specified command, or all available commands and key bindings if none specified.<br /> <span style='color: blue; font-weight: bold'>load</span> Executes the specified file within the current interactive session.<br /> <span style='color: blue; font-weight: bold'>prompt</span> Changes the current prompt settings.<br /> <span style='color: blue; font-weight: bold'>reset</span> Reset the execution environment to the initial state, keep REPL history.<br /> </div><br /> <br /> 그 외에 입력되는 모든 문자열은 "C# 코드"라고 보시면 됩니다. Interactive 창에서 수행되는 모든 C# 명령어는 하나의 문맥을 공유합니다. 지난번 글에서 살펴본 대로라면,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Roslyn 맛보기 - C# 소스 코드를 스크립트 처럼 다루는 방법 ; <a target='tab' href='http://www.sysnet.pe.kr/2/0/1153'>http://www.sysnet.pe.kr/2/0/1153</a> </pre> <br /> 단일 Session 값이 유지된다는 의미가 됩니다. 일련의 명령어들이 같은 Session 인스턴스를 공유하기 때문에 아래의 화면에서처럼 이전 명령어 실행 결과에 영향을 받는 실행 결과를 보여줍니다.<br /> <br /> <img alt='csharp_interactive_2.png' src='/SysWebRes/bbs/csharp_interactive_2.png' /><br /> <br /> <hr style='width: 50%' /><br /> <br /> 처음에는, C# Interactive 기능이 F#에 비해서 과연 많이 쓰일까 하는 의문이 들었는데, 경험상 나름 개발을 하는 동안 간단한 코드들에 대한 검증에서 유용하게 사용할 수 있었습니다. 예를 들어, "<a target='tab' href='http://www.sysnet.pe.kr/2/0/1147'>닷넷에서 지원되는 문자열 인코딩 이름 목록</a>" 글에서 보여지는 간단한 코드들의 경우에 기존에는 일부러 테스트를 위해 콘솔 프로젝트를 별도로 만들어서 확인해야 했는데, 이제는 빠르게 C# Interactive 윈도우에서 그 결과를 확인할 수 있었습니다.<br /> <br /> 사용하다보니, 기왕이면 #help 명령어로 나오는 단축키를 익혀두는 것이 좋겠더군요. ^^ (아래의 목록에서 '빨간색' 항목은 제가 자주 사용하는 단축키입니다.)<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > > #help Keyboard shortcuts: <span style='color: blue; font-weight: bold'>Enter</span> Evaluate the current input if it appears to be complete. <span style='color: blue; font-weight: bold'>Ctrl-Enter</span> If the caret is in current pending input submission, evaluate the entire submission. If the caret is in a previous input block, copy that input text to the end of the buffer. <span style='color: blue; font-weight: bold'>Shift-Enter</span> If the caret is in the current pending input submission, insert a new line. <span style='color: blue; font-weight: bold'>Escape</span> If the caret is in the current pending input submission, delete the entire submission. <span style='color: red; font-weight: bold'>Alt-UpArrow</span> Paste previous input at end of buffer, rotate through history. <span style='color: red; font-weight: bold'>Alt-DownArrow</span> Paste next input at end of buffer, rotate through history. <span style='color: blue; font-weight: bold'>UpArrow</span> Normal editor buffer navigation. <span style='color: blue; font-weight: bold'>DownArrow</span> Normal editor buffer navigation. <span style='color: blue; font-weight: bold'>Ctrl-K, Ctrl-Enter</span> Paste the selection at the end of interactive buffer, leave caret at the end of input. <span style='color: red; font-weight: bold'>Ctrl-E, Ctrl-Enter</span> Paste and execute the selection before any pending input in the interactive buffer. <span style='color: blue; font-weight: bold'>Ctrl-A</span> Alternatively select current input or whole buffer. </pre> <br /> 특히, Interactive 윈도우에서 직접 코드를 입력하기 보다는 C# 코드 윈도우 창에서 입력한 후 특정 영역을 선택하여 실행하는 "Ctrl-E, Ctrl-Enter"기능이 유용했습니다. (아쉽게도 F# Interactive에서 해당 기능의 단축키를 "Alt+Enter"로 선점하고 있어서 C#의 경우에 남은 단축키 영역이 부족해 어쩔 수 없이 복잡해진 것 같습니다. ^^)<br /> <br /> 참고로, 이번 글은 "C:\Program Files (x86)\Microsoft Codename Roslyn CTP\Documentation\Interactive - Executing Code in the Interactive Window.docx" 문서를 요약했다고 보시면 됩니다. ^^<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
3579
(왼쪽의 숫자를 입력해야 합니다.)