• R/O
  • SSH
  • HTTPS

drfx: Commit


Commit MetaInfo

Revision175 (tree)
Time2010-03-21 21:44:58
Authorsasaminn

Log Message

UPGRADE: ルール一覧表示機能を実装

Change Summary

Incremental Difference

--- drfx/trunk/src/Explorer/FxCopRuleWindow.xaml.cs (revision 174)
+++ drfx/trunk/src/Explorer/FxCopRuleWindow.xaml.cs (revision 175)
@@ -18,16 +18,56 @@
1818
1919
2020
21+using Sasa.QualityTools.DrFx.Core;
22+using Sasa.QualityTools.DrFx.Explorer.Rule;
2123 using System;
24+using System.Collections.ObjectModel;
25+using System.ComponentModel;
26+using System.IO;
2227 using System.Windows;
28+using System.Windows.Controls;
29+using System.Windows.Data;
30+using System.Windows.Navigation;
2331
2432 namespace Sasa.QualityTools.DrFx.Explorer
2533 {
2634 public partial class FxCopRuleWindow : Window
2735 {
36+ public Collection<FxCopRule> Rules { get; private set; }
37+
38+
39+
2840 public FxCopRuleWindow()
2941 {
3042 InitializeComponent();
3143 }
44+
45+
46+
47+ protected override void OnContentRendered(EventArgs e)
48+ {
49+ base.OnContentRendered(e);
50+
51+ FxCopProcessConfiguration configuration = new FxCopProcessConfiguration();
52+ string rulesDir = Path.Combine(configuration.FxCopInstallDirectory, "Rules");
53+
54+ FxCopRuleLoader loader = new FxCopRuleLoader();
55+ foreach (string path in Directory.GetFiles(rulesDir))
56+ {
57+ loader.AssemblyPaths.Add(path);
58+ }
59+ Rules = loader.Load();
60+ loader.Translate(Rules);
61+
62+ this.frame.Navigate(new Uri("/FxCopRuleListPage.xaml", UriKind.Relative));
63+ }
64+
65+ private void OnNavigateCompleted(object sender, NavigationEventArgs e)
66+ {
67+ Page page = (Page)e.Content;
68+ page.DataContext = Rules;
69+ ICollectionView collectionView = CollectionViewSource.GetDefaultView(page.DataContext);
70+ collectionView.GroupDescriptions.Add(new PropertyGroupDescription("Category"));
71+ }
3272 }
3373 }
--- drfx/trunk/src/Explorer/FxCopRuleListPage.xaml.cs (revision 174)
+++ drfx/trunk/src/Explorer/FxCopRuleListPage.xaml.cs (revision 175)
@@ -31,6 +31,8 @@
3131 InitializeComponent();
3232 }
3333
34+
35+
3436 private void NavigateToExplorerPage(object sender, RoutedEventArgs e)
3537 {
3638 NavigationService.Navigate(new Uri("/FxCopRuleExplorerPage.xaml", UriKind.Relative));
--- drfx/trunk/src/Explorer/Rule/FxCopRuleLoader.cs (revision 174)
+++ drfx/trunk/src/Explorer/Rule/FxCopRuleLoader.cs (revision 175)
@@ -20,6 +20,7 @@
2020
2121 using Sasa.QualityTools.DrFx.Core.Translation;
2222 using System;
23+using System.Collections.Generic;
2324 using System.Collections.ObjectModel;
2425 using System.IO;
2526 using System.Reflection;
@@ -44,6 +45,27 @@
4445
4546
4647
48+ public void Translate(IEnumerable<FxCopRule> rules)
49+ {
50+ // TODO: 再検討
51+ List<TranslationRule> translationRules = new List<TranslationRule>();
52+ string directory = Path.Combine(Path.GetDirectoryName(GetType().Assembly.Location), "Resources");
53+ foreach (string file in Directory.GetFiles(directory, "*.xml"))
54+ {
55+ string rule = File.ReadAllText(file);
56+ translationRules.AddRange(TranslationRule.Parse(rule));
57+ }
58+ var lookup = translationRules.ToLookup(r => r.CheckId);
59+
60+ foreach (FxCopRule rule in rules)
61+ {
62+ if (lookup.Contains(rule.CheckId))
63+ {
64+ rule.Name = lookup[rule.CheckId].ElementAt(0).Name;
65+ }
66+ }
67+ }
68+
4769 public Collection<FxCopRule> Load()
4870 {
4971 Collection<FxCopRule> rules = new Collection<FxCopRule>();
--- drfx/trunk/src/Core/Translation/Resolution.cs (revision 174)
+++ drfx/trunk/src/Core/Translation/Resolution.cs (revision 175)
@@ -25,12 +25,12 @@
2525 /// <summary>
2626 /// 違反の解決方法を翻訳するための情報を表します。
2727 /// </summary>
28- internal class Resolution
28+ public class Resolution
2929 {
3030 /// <summary>
3131 /// 翻訳結果。
3232 /// </summary>
33- internal string Content { get; set; }
33+ public string Content { get; set; }
3434
3535 /// <summary>
3636 /// 翻訳前のメッセージを特定するパターン。
@@ -39,6 +39,6 @@
3939 /// 解決方法メッセージに埋め込まれている識別子を翻訳結果に埋め込むために、正規表現に
4040 /// よるパターンマッチングを行って、識別子を取り出す必要がある。
4141 /// </remarks>
42- internal string Pattern { get; set; }
42+ public string Pattern { get; set; }
4343 }
4444 }
--- drfx/trunk/src/Core/Translation/TranslationRule.cs (revision 174)
+++ drfx/trunk/src/Core/Translation/TranslationRule.cs (revision 175)
@@ -42,22 +42,22 @@
4242 /// <summary>
4343 /// FxCop ルールのチェック ID。
4444 /// </summary>
45- internal string CheckId { get; private set; }
45+ public string CheckId { get; private set; }
4646
4747 /// <summary>
4848 /// FxCop ルールのカテゴリ。
4949 /// </summary>
50- internal string Category { get; private set; }
50+ public string Category { get; private set; }
5151
5252 /// <summary>
5353 /// FxCop ルール名。
5454 /// </summary>
55- internal string Name { get; private set; }
55+ public string Name { get; private set; }
5656
5757 /// <summary>
5858 /// ルール違反の解決方法を表すオブジェクトのコレクション。
5959 /// </summary>
60- internal IList<Resolution> Resolutions
60+ public IList<Resolution> Resolutions
6161 {
6262 get
6363 {
Show on old repository browser