지난 주에 C++ 코드 범위를 측정하기위한 Visual Studio Extension을 만들기로 결정했습니다. 기본적으로 나는 일상 작업을 위해 나 자신이 필요했다. 제가 생각한 프로젝트는 https://github.com/atlaste/CPPCoverage입니다.텍스트 앞에있는 Visual Studio 장식물이 선택을 방해합니다
대부분 잘 작동합니다. 그러나 장식 레이어에 몇 가지 문제가 있습니다.
프로젝트의 특징 중 하나는 (덮어 쓰지 않은) 코드의 강조 표시를 만드는 것입니다. 그 자체를 강조하는 것은 잘 작동하지만, 비주얼 스튜디오의 선택 코드 방해하는 것 같다
강조 표시에 대한 책임이 관련 코드 :
private void HighlightCoverage(CoverageState[] coverdata, ITextViewLine line)
{
IWpfTextViewLineCollection textViewLines = view.TextViewLines;
int lineno = 1 + view.TextSnapshot.GetLineNumberFromPosition(line.Extent.Start);
CoverageState covered = lineno < coverdata.Length ?
coverdata[lineno] : CoverageState.Irrelevant;
if (covered != CoverageState.Irrelevant)
{
SnapshotSpan span = new SnapshotSpan(view.TextSnapshot,
Span.FromBounds(line.Start, line.End));
Geometry g = textViewLines.GetMarkerGeometry(span);
if (g != null)
{
GeometryDrawing drawing = (covered == CoverageState.Covered) ?
new GeometryDrawing(coveredBrush, coveredPen, g) :
new GeometryDrawing(uncoveredBrush, uncoveredPen, g);
drawing.Freeze();
DrawingImage drawingImage = new DrawingImage(drawing);
drawingImage.Freeze();
Image image = new Image();
image.Source = drawingImage;
//Align the image with the top of the bounds of the text geometry
Canvas.SetLeft(image, g.Bounds.Left);
Canvas.SetTop(image, g.Bounds.Top);
layer.AddAdornment(AdornmentPositioningBehavior.TextRelative,
span, null, image, null);
}
}
}
와 코드의 전체 조각 여기서는 오른쪽 컨텍스트를 찾을 수 있습니다 : https://github.com/atlaste/CPPCoverage/blob/master/CoverageExt/CodeRendering/CodeCoverage.cs.
Q : 누군가 전경 대신 배경에 블록을 렌더링하는 방법을 알려주시겠습니까?
PS : 작업이 주위에 내가 발견로서 당신은에서 불투명도를 설정할 수 있습니다 레이어. 그게 좋은 방법이긴하지만 배경에 레이어를 넣는 것을 선호합니다. – atlaste