다소 늦었 겠지만 Visual Studio Extensibility를 사용하여 직접 빌드 할 수 있습니다. 따라서 사용자 지정 동작도 추가 할 수 있습니다. Inside the Editor: Tags and Classifier. 단계는 다음과 같습니다
1) 에디터 분류 프로젝트 (내장 프로젝트 형식)
2) 삭제를 기존의 클래스 파일
3
) 아래의 코드를 추가를 만듭니다. 그것은 빨간색 코드 부분의 모든 '고토'문을 색상 화됩니다
internal class GotoTagger : ITagger<GotoTag>
{
private ITextSearchService _textSearchService;
private ITextStructureNavigator _textStructureNavigator;
event EventHandler<SnapshotSpanEventArgs> ITagger<GotoTag>.TagsChanged { add { } remove { } }
public GotoTagger(ITextSearchService textSearchService, ITextStructureNavigator textStructureNavigator)
{
_textSearchService = textSearchService;
_textStructureNavigator = textStructureNavigator;
}
public IEnumerable<ITagSpan<GotoTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
if (spans.Count == 0)
yield break;
if (spans.Count > 0)
{
// look for 'goto' occurrences
foreach (SnapshotSpan span in _textSearchService.FindAll(new FindData("goto", spans[0].Snapshot, FindOptions.WholeWord | FindOptions.MatchCase, _textStructureNavigator)))
{
yield return new TagSpan<GotoTag>(span, new GotoTag());
}
}
}
}
[Export(typeof(IViewTaggerProvider))]
[TagType(typeof(TextMarkerTag))]
[ContentType("code")] // only for code portion. Could be changed to csharp to colorize only C# code for example
internal class GotoTaggerProvider : IViewTaggerProvider
{
[Import]
internal ITextSearchService TextSearchService { get; set; }
[Import]
internal ITextStructureNavigatorSelectorService TextStructureNavigatorSelector { get; set; }
public ITagger<T> CreateTagger<T>(ITextView textView, ITextBuffer buffer) where T : ITag
{
if (textView.TextBuffer != buffer)
return null;
return new GotoTagger(TextSearchService, TextStructureNavigatorSelector.GetTextStructureNavigator(buffer)) as ITagger<T>;
}
}
internal class GotoTag : TextMarkerTag
{
public GotoTag() : base("goto") { }
}
[Export(typeof(EditorFormatDefinition))]
[Name("goto")]
[UserVisible(true)]
internal class GotoFormatDefinition : MarkerFormatDefinition
{
public GotoFormatDefinition()
{
BackgroundColor = Colors.Red;
ForegroundColor = Colors.White;
DisplayName = "Goto Word";
ZOrder = 5;
}
}
나쁜 가독성 우리가 goto''사용하여 피할 이유는 정확히 이유 아닙니까? – Carsten
글쎄, 내 생각 엔 도구 -> 옵션 -> 텍스트 편집기 -> C# -> 서식 -> 들여 쓰기 -> 레이블 들여 쓰기 -> 모든 레이블을 빠르게 만들 수있는 가장 왼쪽 열에 레이블을 배치하십시오. 주목할 만하다. – Agent007
언급 한 확장 기능은 GOTO 문을 찾는 것이 아니라 코드 내의 탐색 사이에 사용됩니다. –