• R/O
  • SSH
  • HTTPS

drfx: Commit


Commit MetaInfo

Revision145 (tree)
Time2010-02-20 20:12:32
Authorsasaminn

Log Message

UPGRADE: FxCop レポート表示画面に、違反したソースコードの一部を表示する機能を追加

Change Summary

Incremental Difference

--- drfx/trunk/src/Explorer/FxCopIssueDetailWidget.xaml.cs (revision 144)
+++ drfx/trunk/src/Explorer/FxCopIssueDetailWidget.xaml.cs (revision 145)
@@ -1,20 +1,52 @@
11 using Sasa.QualityTools.DrFx.Explorer.Report;
22 using System;
33 using System.Collections.Generic;
4+using System.Collections.ObjectModel;
45 using System.IO;
56 using System.Windows;
67 using System.Windows.Controls;
8+using System.Windows.Data;
79
810 namespace Sasa.QualityTools.DrFx.Explorer
911 {
1012 public partial class FxCopIssueDetailWidget : UserControl
1113 {
14+ public static DependencyProperty FxCopIssueRelationshipProperty = DependencyProperty.Register("FxCopIssueRelationship", typeof(FxCopIssueRelationship), typeof(FxCopIssueDetailWidget), new PropertyMetadata(OnFxCopIssueDetailWidgetChanged));
15+
16+ private ObservableCollection<SourceCodeLine> lines = new ObservableCollection<SourceCodeLine>();
17+
18+
19+
20+ public FxCopIssueRelationship FxCopIssueRelationship
21+ {
22+ get
23+ {
24+ return (FxCopIssueRelationship)GetValue(FxCopIssueRelationshipProperty);
25+ }
26+ set
27+ {
28+ SetValue(FxCopIssueRelationshipProperty, value);
29+
30+ }
31+ }
32+
33+ public ObservableCollection<SourceCodeLine> Lines
34+ {
35+ get
36+ {
37+ return this.lines;
38+ }
39+ }
40+
41+
42+
1243 public FxCopIssueDetailWidget()
1344 {
1445 InitializeComponent();
15- DataContextChanged += OnDataContextChanged;
1646 }
1747
48+
49+
1850 internal static List<SourceCodeLine> GetViolationCodeLines(string filePath, int lineNumber)
1951 {
2052 if (String.IsNullOrEmpty(filePath) || File.Exists(filePath) == false || lineNumber <= 0)
@@ -22,7 +54,7 @@
2254 return new List<SourceCodeLine>();
2355 }
2456
25- int start = (lineNumber < 6) ? 0 : lineNumber - 6;
57+ int start = (lineNumber < 6) ? 0 : lineNumber -6;
2658 int end = lineNumber + 5;
2759
2860 List<SourceCodeLine> lines = new List<SourceCodeLine>();
@@ -48,7 +80,6 @@
4880 }
4981 lines.Add(new SourceCodeLine { LineNumber = i + 1, Text = line.Replace(Environment.NewLine, String.Empty), IsViolationLine = (i + 1 == lineNumber) });
5082 }
51- return lines;
5283 }
5384 }
5485 catch (IOException)
@@ -63,8 +94,9 @@
6394 return lines;
6495 }
6596
66- private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
97+ private static void OnFxCopIssueDetailWidgetChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
6798 {
99+ FxCopIssueDetailWidget widget = (FxCopIssueDetailWidget)sender;
68100 FxCopIssueRelationship relationship = e.NewValue as FxCopIssueRelationship;
69101 if (relationship == null)
70102 {
@@ -71,7 +103,14 @@
71103 return;
72104 }
73105
74-
106+ widget.lines.Clear();
107+ if (relationship.Issue.Line.HasValue)
108+ {
109+ foreach (SourceCodeLine line in GetViolationCodeLines(relationship.Issue.FilePath, relationship.Issue.Line.Value))
110+ {
111+ widget.lines.Add(line);
112+ }
113+ }
75114 }
76115 }
77116 }
Show on old repository browser