Browse Source

Worked on FxCop integration.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1233 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
05c43ceb3f
  1. 1
      src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin
  2. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  3. 1
      src/AddIns/BackendBindings/ILAsmBinding/Project/ILAsmBinding.addin
  4. 1
      src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.addin
  5. 10
      src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin
  6. 1
      src/AddIns/Misc/CodeAnalysis/CodeAnalysis.csproj
  7. 43
      src/AddIns/Misc/CodeAnalysis/Src/AnalysisProjectOptions.Designer.cs
  8. 123
      src/AddIns/Misc/CodeAnalysis/Src/AnalysisProjectOptions.cs
  9. 12
      src/AddIns/Misc/CodeAnalysis/Src/AnalysisProjectOptionsPanel.cs
  10. 26
      src/AddIns/Misc/CodeAnalysis/Src/CheckCurrentProjectCommand.cs
  11. 21
      src/AddIns/Misc/CodeAnalysis/Src/FxCopRule.cs
  12. 102
      src/AddIns/Misc/CodeAnalysis/Src/FxCopWrapper.cs
  13. 3
      src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin
  14. 18
      src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs
  15. 2
      src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.CodeAnalysis.targets
  16. 19
      src/Main/Base/Project/Src/Commands/BuildCommands.cs
  17. 14
      src/Main/Base/Project/Src/Gui/Components/StringListEditor.cs
  18. 8
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  19. 8
      src/Main/Base/Project/Src/Project/IProject.cs
  20. 2
      src/Main/Base/Project/Src/Project/MSBuildEngine.cs
  21. 27
      src/Main/Base/Project/Src/Project/MSBuildProject.cs
  22. 12
      src/Main/Base/Project/Src/Project/Solution/Solution.cs
  23. 2
      src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs
  24. 2
      src/Main/GlobalAssemblyInfo.template

1
src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.addin

@ -122,6 +122,7 @@
<!--<DialogPanel id = "Publish" <!--<DialogPanel id = "Publish"
label = "${res:Dialog.ProjectOptions.Publish}" label = "${res:Dialog.ProjectOptions.Publish}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.Publish"/>--> class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.Publish"/>-->
<Include id = "AllManaged" path="/SharpDevelop/BackendBindings/ProjectOptions/AllManaged"/>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/LanguageBindings"> <Path name = "/SharpDevelop/Workbench/LanguageBindings">

1
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin

@ -70,6 +70,7 @@
<!--<DialogPanel id = "Publish" <!--<DialogPanel id = "Publish"
label = "${res:Dialog.ProjectOptions.Publish}" label = "${res:Dialog.ProjectOptions.Publish}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.Publish"/>--> class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.Publish"/>-->
<Include id = "AllManaged" path="/SharpDevelop/BackendBindings/ProjectOptions/AllManaged"/>
</Path> </Path>
<Path name = "/AddIns/DefaultTextEditor/Formatter/C#"> <Path name = "/AddIns/DefaultTextEditor/Formatter/C#">

1
src/AddIns/BackendBindings/ILAsmBinding/Project/ILAsmBinding.addin

@ -45,6 +45,7 @@
<DialogPanel id = "DebugOptions" <DialogPanel id = "DebugOptions"
label = "${res:Dialog.ProjectOptions.DebugOptions}" label = "${res:Dialog.ProjectOptions.DebugOptions}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/> class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
<Include id = "AllManaged" path="/SharpDevelop/BackendBindings/ProjectOptions/AllManaged"/>
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/LanguageBindings"> <Path name = "/SharpDevelop/Workbench/LanguageBindings">

1
src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.addin

@ -75,6 +75,7 @@
<DialogPanel id = "ProjectImports" <DialogPanel id = "ProjectImports"
label = "${res:Dialog.ProjectOptions.ProjectImports}" label = "${res:Dialog.ProjectOptions.ProjectImports}"
class = "VBNetBinding.OptionPanels.ProjectImports"/> class = "VBNetBinding.OptionPanels.ProjectImports"/>
<Include id = "AllManaged" path="/SharpDevelop/BackendBindings/ProjectOptions/AllManaged"/>
</Path> </Path>
<Path name = "/AddIns/DefaultTextEditor/CodeCompletion"> <Path name = "/AddIns/DefaultTextEditor/CodeCompletion">

10
src/AddIns/Misc/CodeAnalysis/CodeAnalysis.addin

@ -15,10 +15,16 @@
<String id="CodeAnalysis" text = "$(SharpDevelopBinPath)/SharpDevelop.CodeAnalysis.targets"/> <String id="CodeAnalysis" text = "$(SharpDevelopBinPath)/SharpDevelop.CodeAnalysis.targets"/>
</Path> </Path>
<Path name = "/SharpDevelop/BackendBindings/ProjectOptions/C#"> <Path name = "/SharpDevelop/BackendBindings/ProjectOptions/AllManaged">
<DialogPanel id = "CodeAnalysis" <DialogPanel id = "CodeAnalysis"
label = "${res:ICSharpCode.CodeAnalysis}" label = "${res:ICSharpCode.CodeAnalysis}"
insertafter = "Publish"
class = "ICSharpCode.CodeAnalysis.AnalysisProjectOptionsPanel"/> class = "ICSharpCode.CodeAnalysis.AnalysisProjectOptionsPanel"/>
</Path> </Path>
<Path name = "/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions">
<MenuItem id = "CheckWithFxCop"
label = "${res:ICSharpCode.CodeAnalysis.CheckWithFxCop}"
class = "ICSharpCode.CodeAnalysis.CheckCurrentProjectCommand"
insertafter = "Separator2" insertbefore="SetConfiguration"/>
</Path>
</AddIn> </AddIn>

1
src/AddIns/Misc/CodeAnalysis/CodeAnalysis.csproj

@ -60,6 +60,7 @@
</EmbeddedResource> </EmbeddedResource>
<Compile Include="Src\FxCopWrapper.cs" /> <Compile Include="Src\FxCopWrapper.cs" />
<Compile Include="Src\FxCopRule.cs" /> <Compile Include="Src\FxCopRule.cs" />
<Compile Include="Src\CheckCurrentProjectCommand.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> <ProjectReference Include="..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">

43
src/AddIns/Misc/CodeAnalysis/Src/AnalysisProjectOptions.Designer.cs generated

@ -1,9 +1,10 @@
/* // <file>
* Created by SharpDevelop. // <copyright see="prj:///doc/copyright.txt"/>
* User: Daniel Grunwald // <license see="prj:///doc/license.txt"/>
* Date: ${DATE} // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
* Time: ${TIME} // <version>$Revision$</version>
*/ // </file>
namespace ICSharpCode.CodeAnalysis namespace ICSharpCode.CodeAnalysis
{ {
partial class AnalysisProjectOptions : System.Windows.Forms.UserControl partial class AnalysisProjectOptions : System.Windows.Forms.UserControl
@ -40,6 +41,7 @@ namespace ICSharpCode.CodeAnalysis
this.warningOrErrorLabel = new System.Windows.Forms.Label(); this.warningOrErrorLabel = new System.Windows.Forms.Label();
this.enableCheckBox = new System.Windows.Forms.CheckBox(); this.enableCheckBox = new System.Windows.Forms.CheckBox();
this.ruleTreeView = new System.Windows.Forms.TreeView(); this.ruleTreeView = new System.Windows.Forms.TreeView();
this.changeRuleAssembliesButton = new System.Windows.Forms.Button();
splitContainer1 = new System.Windows.Forms.SplitContainer(); splitContainer1 = new System.Windows.Forms.SplitContainer();
panel1 = new System.Windows.Forms.Panel(); panel1 = new System.Windows.Forms.Panel();
splitContainer1.Panel1.SuspendLayout(); splitContainer1.Panel1.SuspendLayout();
@ -67,7 +69,7 @@ namespace ICSharpCode.CodeAnalysis
splitContainer1.Panel2.RightToLeft = System.Windows.Forms.RightToLeft.No; splitContainer1.Panel2.RightToLeft = System.Windows.Forms.RightToLeft.No;
splitContainer1.RightToLeft = System.Windows.Forms.RightToLeft.No; splitContainer1.RightToLeft = System.Windows.Forms.RightToLeft.No;
splitContainer1.Size = new System.Drawing.Size(375, 17); splitContainer1.Size = new System.Drawing.Size(375, 17);
splitContainer1.SplitterDistance = 208; splitContainer1.SplitterDistance = 214;
splitContainer1.SplitterWidth = 2; splitContainer1.SplitterWidth = 2;
splitContainer1.TabIndex = 1; splitContainer1.TabIndex = 1;
// //
@ -77,7 +79,7 @@ namespace ICSharpCode.CodeAnalysis
this.ruleLabel.Dock = System.Windows.Forms.DockStyle.Fill; this.ruleLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.ruleLabel.Location = new System.Drawing.Point(0, 0); this.ruleLabel.Location = new System.Drawing.Point(0, 0);
this.ruleLabel.Name = "ruleLabel"; this.ruleLabel.Name = "ruleLabel";
this.ruleLabel.Size = new System.Drawing.Size(208, 17); this.ruleLabel.Size = new System.Drawing.Size(214, 17);
this.ruleLabel.TabIndex = 0; this.ruleLabel.TabIndex = 0;
this.ruleLabel.Text = "${res:ICSharpCode.CodeAnalysis.Rule}"; this.ruleLabel.Text = "${res:ICSharpCode.CodeAnalysis.Rule}";
// //
@ -87,7 +89,7 @@ namespace ICSharpCode.CodeAnalysis
this.warningOrErrorLabel.Dock = System.Windows.Forms.DockStyle.Fill; this.warningOrErrorLabel.Dock = System.Windows.Forms.DockStyle.Fill;
this.warningOrErrorLabel.Location = new System.Drawing.Point(0, 0); this.warningOrErrorLabel.Location = new System.Drawing.Point(0, 0);
this.warningOrErrorLabel.Name = "warningOrErrorLabel"; this.warningOrErrorLabel.Name = "warningOrErrorLabel";
this.warningOrErrorLabel.Size = new System.Drawing.Size(165, 17); this.warningOrErrorLabel.Size = new System.Drawing.Size(159, 17);
this.warningOrErrorLabel.TabIndex = 0; this.warningOrErrorLabel.TabIndex = 0;
this.warningOrErrorLabel.Text = "${res:ICSharpCode.CodeAnalysis.ProjectOptions.WarningOrError}"; this.warningOrErrorLabel.Text = "${res:ICSharpCode.CodeAnalysis.ProjectOptions.WarningOrError}";
// //
@ -97,7 +99,7 @@ namespace ICSharpCode.CodeAnalysis
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
panel1.BackColor = System.Drawing.SystemColors.InactiveCaption; panel1.BackColor = System.Drawing.SystemColors.InactiveCaption;
panel1.Controls.Add(splitContainer1); panel1.Controls.Add(splitContainer1);
panel1.Location = new System.Drawing.Point(15, 33); panel1.Location = new System.Drawing.Point(15, 57);
panel1.Name = "panel1"; panel1.Name = "panel1";
panel1.Padding = new System.Windows.Forms.Padding(1); panel1.Padding = new System.Windows.Forms.Padding(1);
panel1.Size = new System.Drawing.Size(377, 19); panel1.Size = new System.Drawing.Size(377, 19);
@ -111,7 +113,7 @@ namespace ICSharpCode.CodeAnalysis
this.enableCheckBox.Name = "enableCheckBox"; this.enableCheckBox.Name = "enableCheckBox";
this.enableCheckBox.Size = new System.Drawing.Size(376, 24); this.enableCheckBox.Size = new System.Drawing.Size(376, 24);
this.enableCheckBox.TabIndex = 0; this.enableCheckBox.TabIndex = 0;
this.enableCheckBox.Text = "${res:ICSharpCode.CodeAnalysis.ProjectOptions.Enable}"; this.enableCheckBox.Text = "${res:ICSharpCode.CodeAnalysis.ProjectOptions.RunOnBuild}";
this.enableCheckBox.UseVisualStyleBackColor = true; this.enableCheckBox.UseVisualStyleBackColor = true;
// //
// ruleTreeView // ruleTreeView
@ -121,19 +123,32 @@ namespace ICSharpCode.CodeAnalysis
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.ruleTreeView.CheckBoxes = true; this.ruleTreeView.CheckBoxes = true;
this.ruleTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText; this.ruleTreeView.DrawMode = System.Windows.Forms.TreeViewDrawMode.OwnerDrawText;
this.ruleTreeView.Location = new System.Drawing.Point(15, 51); this.ruleTreeView.Location = new System.Drawing.Point(15, 75);
this.ruleTreeView.Name = "ruleTreeView"; this.ruleTreeView.Name = "ruleTreeView";
this.ruleTreeView.RightToLeft = System.Windows.Forms.RightToLeft.No; this.ruleTreeView.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.ruleTreeView.Size = new System.Drawing.Size(377, 190); this.ruleTreeView.Size = new System.Drawing.Size(377, 166);
this.ruleTreeView.TabIndex = 2; this.ruleTreeView.TabIndex = 2;
this.ruleTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.RuleTreeViewAfterCheck); this.ruleTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.RuleTreeViewAfterCheck);
this.ruleTreeView.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.RuleTreeViewDrawNode); this.ruleTreeView.DrawNode += new System.Windows.Forms.DrawTreeNodeEventHandler(this.RuleTreeViewDrawNode);
this.ruleTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RuleTreeViewMouseDown); this.ruleTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.RuleTreeViewMouseDown);
// //
// changeRuleAssembliesButton
//
this.changeRuleAssembliesButton.AutoSize = true;
this.changeRuleAssembliesButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.changeRuleAssembliesButton.Location = new System.Drawing.Point(15, 28);
this.changeRuleAssembliesButton.Name = "changeRuleAssembliesButton";
this.changeRuleAssembliesButton.Size = new System.Drawing.Size(387, 23);
this.changeRuleAssembliesButton.TabIndex = 4;
this.changeRuleAssembliesButton.Text = "${res:ICSharpCode.CodeAnalysis.ProjectOptions.AddRemoveRuleAssembly}";
this.changeRuleAssembliesButton.UseVisualStyleBackColor = true;
this.changeRuleAssembliesButton.Click += new System.EventHandler(this.ChangeRuleAssembliesButtonClick);
//
// AnalysisProjectOptions // AnalysisProjectOptions
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.changeRuleAssembliesButton);
this.Controls.Add(this.ruleTreeView); this.Controls.Add(this.ruleTreeView);
this.Controls.Add(this.enableCheckBox); this.Controls.Add(this.enableCheckBox);
this.Controls.Add(panel1); this.Controls.Add(panel1);
@ -144,7 +159,9 @@ namespace ICSharpCode.CodeAnalysis
splitContainer1.ResumeLayout(false); splitContainer1.ResumeLayout(false);
panel1.ResumeLayout(false); panel1.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
private System.Windows.Forms.Button changeRuleAssembliesButton;
private System.Windows.Forms.Label warningOrErrorLabel; private System.Windows.Forms.Label warningOrErrorLabel;
private System.Windows.Forms.TreeView ruleTreeView; private System.Windows.Forms.TreeView ruleTreeView;
private System.Windows.Forms.Label ruleLabel; private System.Windows.Forms.Label ruleLabel;

123
src/AddIns/Misc/CodeAnalysis/Src/AnalysisProjectOptions.cs

@ -1,15 +1,16 @@
/* // <file>
* Created by SharpDevelop. // <copyright see="prj:///doc/copyright.txt"/>
* User: Daniel Grunwald // <license see="prj:///doc/license.txt"/>
* Date: 28.02.2006 // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
* Time: 15:52 // <version>$Revision$</version>
*/ // </file>
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -33,6 +34,7 @@ namespace ICSharpCode.CodeAnalysis
enableCheckBox.Text = StringParser.Parse(enableCheckBox.Text); enableCheckBox.Text = StringParser.Parse(enableCheckBox.Text);
ruleLabel.Text = StringParser.Parse(ruleLabel.Text); ruleLabel.Text = StringParser.Parse(ruleLabel.Text);
warningOrErrorLabel.Text = StringParser.Parse(warningOrErrorLabel.Text); warningOrErrorLabel.Text = StringParser.Parse(warningOrErrorLabel.Text);
changeRuleAssembliesButton.Text = StringParser.Parse(changeRuleAssembliesButton.Text);
ruleLabel.SizeChanged += delegate { ruleTreeView.Invalidate(); }; ruleLabel.SizeChanged += delegate { ruleTreeView.Invalidate(); };
} }
@ -44,12 +46,18 @@ namespace ICSharpCode.CodeAnalysis
base.OnVisibleChanged(e); base.OnVisibleChanged(e);
if (ruleTreeView.Nodes.Count == 0 && this.Visible) { if (ruleTreeView.Nodes.Count == 0 && this.Visible) {
FxCopWrapper.GetRuleList(Callback); ReloadRuleList();
}
}
void ReloadRuleList()
{
ruleTreeView.Nodes.Clear();
FxCopWrapper.GetRuleList(GetRuleAssemblyList(true), Callback);
if (ruleTreeView.Nodes.Count == 0) { if (ruleTreeView.Nodes.Count == 0) {
ruleTreeView.Nodes.Add(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.LoadingRules}")); ruleTreeView.Nodes.Add(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.LoadingRules}"));
} }
} }
}
void Callback(List<FxCopCategory> ruleList) void Callback(List<FxCopCategory> ruleList)
{ {
@ -57,6 +65,7 @@ namespace ICSharpCode.CodeAnalysis
WorkbenchSingleton.SafeThreadAsyncCall((Action<List<FxCopCategory>>)Callback, ruleList); WorkbenchSingleton.SafeThreadAsyncCall((Action<List<FxCopCategory>>)Callback, ruleList);
} else { } else {
ruleTreeView.Nodes.Clear(); ruleTreeView.Nodes.Clear();
rules.Clear();
if (ruleList == null || ruleList.Count == 0) { if (ruleList == null || ruleList.Count == 0) {
ruleTreeView.Nodes.Add(new TreeNode(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.CannotFindFxCop}"))); ruleTreeView.Nodes.Add(new TreeNode(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.CannotFindFxCop}")));
ruleTreeView.Nodes.Add(new TreeNode(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.SpecifyFxCopPath}"))); ruleTreeView.Nodes.Add(new TreeNode(StringParser.Parse("${res:ICSharpCode.CodeAnalysis.ProjectOptions.SpecifyFxCopPath}")));
@ -65,7 +74,7 @@ namespace ICSharpCode.CodeAnalysis
CategoryTreeNode catNode = new CategoryTreeNode(cat); CategoryTreeNode catNode = new CategoryTreeNode(cat);
ruleTreeView.Nodes.Add(catNode); ruleTreeView.Nodes.Add(catNode);
foreach (RuleTreeNode ruleNode in catNode.Nodes) { foreach (RuleTreeNode ruleNode in catNode.Nodes) {
rules.Add(ruleNode.Identifier, ruleNode); rules[ruleNode.Identifier] = ruleNode;
} }
} }
initSuccess = true; initSuccess = true;
@ -116,7 +125,7 @@ namespace ICSharpCode.CodeAnalysis
public RuleTreeNode(FxCopRule rule) public RuleTreeNode(FxCopRule rule)
{ {
this.rule = rule; this.rule = rule;
this.Text = rule.DisplayName; this.Text = rule.CheckId + " : " + rule.DisplayName;
} }
public string Identifier { public string Identifier {
@ -245,6 +254,30 @@ namespace ICSharpCode.CodeAnalysis
} }
#endregion #endregion
#region Rule Assemblies Property
string ruleAssemblies;
const string DefaultRuleAssemblies = @"$(FxCopDir)\rules";
public string RuleAssemblies {
get {
return ruleAssemblies;
}
set {
if (string.IsNullOrEmpty(value)) {
value = DefaultRuleAssemblies;
}
if (ruleAssemblies != value) {
ruleAssemblies = value;
if (initSuccess) {
OnOptionChanged(EventArgs.Empty);
ReloadRuleList();
}
}
}
}
#endregion
#region ConfigurationGuiBinding #region ConfigurationGuiBinding
public CheckBox EnableCheckBox { public CheckBox EnableCheckBox {
get { get {
@ -272,11 +305,14 @@ namespace ICSharpCode.CodeAnalysis
public override void Load() public override void Load()
{ {
po.RuleString = Get(""); po.RuleString = Get("");
PropertyStorageLocations tmp;
po.RuleAssemblies = Helper.GetProperty("CodeAnalysisRuleAssemblies", "", out tmp);
} }
public override bool Save() public override bool Save()
{ {
Set(po.RuleString); Set(po.RuleString);
Helper.SetProperty("CodeAnalysisRuleAssemblies", (po.RuleAssemblies == DefaultRuleAssemblies) ? "" : po.RuleAssemblies, Location);
return true; return true;
} }
} }
@ -339,5 +375,72 @@ namespace ICSharpCode.CodeAnalysis
OnOptionChanged(EventArgs.Empty); OnOptionChanged(EventArgs.Empty);
} }
} }
string[] GetRuleAssemblyList(bool replacePath)
{
List<string> list = new List<string>();
foreach (string dir in ruleAssemblies.Split(';')) {
if (string.Equals(dir, "$(FxCopDir)\\rules", StringComparison.OrdinalIgnoreCase))
continue;
if (string.Equals(dir, "$(FxCopDir)/rules", StringComparison.OrdinalIgnoreCase))
continue;
if (replacePath) {
list.Add(Regex.Replace(dir, @"\$\(FxCopDir\)", FxCopWrapper.FindFxCopPath(), RegexOptions.CultureInvariant | RegexOptions.IgnoreCase));
} else {
list.Add(dir);
}
}
return list.ToArray();
}
void ChangeRuleAssembliesButtonClick(object sender, EventArgs e)
{
using (Form frm = new Form()) {
frm.Text = changeRuleAssembliesButton.Text;
StringListEditor ed = new StringListEditor();
ed.Dock = DockStyle.Fill;
ed.ManualOrder = false;
ed.BrowseForDirectory = true;
ed.AutoAddAfterBrowse = true;
ed.TitleText = "${res:ICSharpCode.CodeAnalysis.ProjectOptions.ChooseRuleAssemblyDirectory}";
ed.LoadList(GetRuleAssemblyList(false));
FlowLayoutPanel p = new FlowLayoutPanel();
p.Dock = DockStyle.Bottom;
p.FlowDirection = FlowDirection.RightToLeft;
Button btn = new Button();
p.Height = btn.Height + 8;
btn.DialogResult = DialogResult.Cancel;
btn.Text = ResourceService.GetString("Global.CancelButtonText");
frm.CancelButton = btn;
p.Controls.Add(btn);
btn = new Button();
btn.DialogResult = DialogResult.OK;
btn.Text = ResourceService.GetString("Global.OKButtonText");
frm.AcceptButton = btn;
p.Controls.Add(btn);
frm.Controls.Add(ed);
frm.Controls.Add(p);
frm.FormBorderStyle = FormBorderStyle.FixedDialog;
frm.MaximizeBox = false;
frm.MinimizeBox = false;
frm.ClientSize = new Size(400, 300);
frm.StartPosition = FormStartPosition.CenterParent;
if (frm.ShowDialog(FindForm()) == DialogResult.OK) {
StringBuilder b = new StringBuilder(DefaultRuleAssemblies);
foreach (string asm in ed.GetList()) {
b.Append(';');
b.Append(asm);
}
this.RuleAssemblies = b.ToString();
}
}
}
} }
} }

12
src/AddIns/Misc/CodeAnalysis/Src/AnalysisProjectOptionsPanel.cs

@ -1,9 +1,9 @@
/* // <file>
* Created by SharpDevelop. // <copyright see="prj:///doc/copyright.txt"/>
* User: Daniel Grunwald // <license see="prj:///doc/license.txt"/>
* Date: 28.02.2006 // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
* Time: 15:29 // <version>$Revision$</version>
*/ // </file>
using System; using System;
using System.Drawing; using System.Drawing;

26
src/AddIns/Misc/CodeAnalysis/Src/CheckCurrentProjectCommand.cs

@ -0,0 +1,26 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Project.Commands;
namespace ICSharpCode.CodeAnalysis
{
public class CheckCurrentProjectCommand : AbstractMenuCommand
{
public override void Run()
{
IProject p = ProjectService.CurrentProject;
if (p == null) return;
RebuildProject build = new RebuildProject(p);
build.AdditionalProperties.Add("RunCodeAnalysis", "true");
build.Run();
}
}
}

21
src/AddIns/Misc/CodeAnalysis/Src/FxCopRule.cs

@ -1,9 +1,9 @@
/* // <file>
* Created by SharpDevelop. // <copyright see="prj:///doc/copyright.txt"/>
* User: Daniel Grunwald // <license see="prj:///doc/license.txt"/>
* Date: 28.02.2006 // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
* Time: 17:16 // <version>$Revision$</version>
*/ // </file>
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -67,6 +67,8 @@ namespace ICSharpCode.CodeAnalysis
FxCopRule o = (FxCopRule)obj; FxCopRule o = (FxCopRule)obj;
int r = categoryName.CompareTo(o.categoryName); int r = categoryName.CompareTo(o.categoryName);
if (r != 0) return r; if (r != 0) return r;
r = checkId.CompareTo(o.checkId);
if (r != 0) return r;
return displayName.CompareTo(o.displayName); return displayName.CompareTo(o.displayName);
} }
} }
@ -74,16 +76,11 @@ namespace ICSharpCode.CodeAnalysis
public class FxCopCategory public class FxCopCategory
{ {
readonly string name; readonly string name;
readonly string displayName;
readonly List<FxCopRule> rules = new List<FxCopRule>(); readonly List<FxCopRule> rules = new List<FxCopRule>();
public FxCopCategory(string name) public FxCopCategory(string name)
{ {
this.name = name; this.name = name;
if (name.StartsWith("Microsoft."))
displayName = name.Substring(10);
else
displayName = name;
} }
public string Name { public string Name {
@ -94,7 +91,7 @@ namespace ICSharpCode.CodeAnalysis
public string DisplayName { public string DisplayName {
get { get {
return displayName; return name;
} }
} }

102
src/AddIns/Misc/CodeAnalysis/Src/FxCopWrapper.cs

@ -1,9 +1,9 @@
/* // <file>
* Created by SharpDevelop. // <copyright see="prj:///doc/copyright.txt"/>
* User: Daniel Grunwald // <license see="prj:///doc/license.txt"/>
* Date: 28.02.2006 // <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
* Time: 16:24 // <version>$Revision$</version>
*/ // </file>
using System; using System;
using System.Collections; using System.Collections;
@ -17,8 +17,40 @@ namespace ICSharpCode.CodeAnalysis
{ {
public static class FxCopWrapper public static class FxCopWrapper
{ {
static List<FxCopCategory> rules = new List<FxCopCategory>(); static Dictionary<string[], List<FxCopCategory>> ruleDict = new Dictionary<string[], List<FxCopCategory>>(new ArrayHashCodeProvider());
static List<Action<List<FxCopCategory>>> callbacks = new List<Action<List<FxCopCategory>>>();
class ArrayHashCodeProvider : IEqualityComparer<string[]>
{
public bool Equals(string[] x, string[] y)
{
if (x == y) return true;
if (x == null || y == null) return false;
if (x.Length != y.Length) return false;
for (int i = 0; i < x.Length; i++) {
if (StringComparer.OrdinalIgnoreCase.Equals(x[i], y[i])) return false;
}
return true;
}
public int GetHashCode(string[] obj)
{
int hashcode = 0;
foreach (string e in obj) {
hashcode ^= StringComparer.OrdinalIgnoreCase.GetHashCode(e);
}
return hashcode;
}
}
class Request
{
public string[] ruleAssemblies;
public Action<List<FxCopCategory>> callback;
public Request(string[] ruleAssemblies, Action<List<FxCopCategory>> callback)
{
this.ruleAssemblies = ruleAssemblies;
this.callback = callback;
}
}
/// <summary> /// <summary>
/// Gets the rules supported by the current FxCop version. The rules are loaded on a separate /// Gets the rules supported by the current FxCop version. The rules are loaded on a separate
@ -26,20 +58,18 @@ namespace ICSharpCode.CodeAnalysis
/// Warning: the callback might be fired on the current thread if the rules are already loaded, /// Warning: the callback might be fired on the current thread if the rules are already loaded,
/// or on another thread! /// or on another thread!
/// </summary> /// </summary>
public static void GetRuleList(Action<List<FxCopCategory>> callback) public static void GetRuleList(string[] ruleAssemblies, Action<List<FxCopCategory>> callback)
{ {
int count; if (ruleAssemblies == null)
lock (rules) { throw new ArgumentNullException("ruleAssemblies");
count = rules.Count; List<FxCopCategory> rules = null;
if (count == 0) { lock (ruleDict) {
callbacks.Add(callback); if (!ruleDict.TryGetValue(ruleAssemblies, out rules)) {
if (callbacks.Count == 1) {
// Start the thread: // Start the thread:
System.Threading.ThreadPool.QueueUserWorkItem(RunGetRuleList); System.Threading.ThreadPool.QueueUserWorkItem(RunGetRuleList, new Request(ruleAssemblies, callback));
}
} }
} }
if (count > 0) { if (rules != null) {
callback(rules); callback(rules);
} }
} }
@ -88,27 +118,26 @@ namespace ICSharpCode.CodeAnalysis
static void RunGetRuleList(object state) static void RunGetRuleList(object state)
{ {
Request request = (Request)state;
LoggingService.Debug("Trying to find FxCop rules"); LoggingService.Debug("Trying to find FxCop rules");
string fxCopPath = FindFxCopPath(); string fxCopPath = FindFxCopPath();
List<FxCopCategory> rules;
if (fxCopPath != null) { if (fxCopPath != null) {
try { try {
GetRuleListAndSort(fxCopPath); rules = GetRuleListAndSort(fxCopPath, request.ruleAssemblies);
} catch (Exception ex) { } catch (Exception ex) {
LoggingService.Warn(ex); LoggingService.Warn(ex);
rules = new List<FxCopCategory>();
} }
} else {
rules = new List<FxCopCategory>();
} }
Action<List<FxCopCategory>>[] callbacks_tmp; LoggingService.Debug("Finished getting FxCop rules, invoking callback");
lock (rules) { request.callback(rules);
callbacks_tmp = callbacks.ToArray();
callbacks.Clear();
}
LoggingService.Debug("Finished getting FxCop rules, invoking " + callbacks_tmp.Length + " callback");
foreach (Action<List<FxCopCategory>> callback in callbacks_tmp) {
callback(rules);
}
} }
static void GetRuleListAndSort(string fxCopPath) static List<FxCopCategory> GetRuleListAndSort(string fxCopPath, string[] ruleAssemblies)
{ {
AppDomainSetup setup = new AppDomainSetup(); AppDomainSetup setup = new AppDomainSetup();
setup.DisallowCodeDownload = true; setup.DisallowCodeDownload = true;
@ -117,7 +146,7 @@ namespace ICSharpCode.CodeAnalysis
string[][] ruleTextList; string[][] ruleTextList;
try { try {
ruleTextList = (string[][])AppDomainLaunchHelper.LaunchInAppDomain(domain, typeof(FxCopWrapper), "GetRuleListInCurrentAppDomain", fxCopPath); ruleTextList = (string[][])AppDomainLaunchHelper.LaunchInAppDomain(domain, typeof(FxCopWrapper), "GetRuleListInCurrentAppDomain", fxCopPath, ruleAssemblies);
} finally { } finally {
AppDomain.Unload(domain); AppDomain.Unload(domain);
} }
@ -130,7 +159,8 @@ namespace ICSharpCode.CodeAnalysis
} }
Array.Sort(ruleList); Array.Sort(ruleList);
lock (rules) { List<FxCopCategory> rules = new List<FxCopCategory>();
lock (ruleDict) {
FxCopCategory cat = null; FxCopCategory cat = null;
foreach (FxCopRule rule in ruleList) { foreach (FxCopRule rule in ruleList) {
if (cat == null || cat.Name != rule.CategoryName) { if (cat == null || cat.Name != rule.CategoryName) {
@ -139,7 +169,9 @@ namespace ICSharpCode.CodeAnalysis
} }
cat.Rules.Add(rule); cat.Rules.Add(rule);
} }
ruleDict[ruleAssemblies] = rules;
} }
return rules;
} }
// We don't want to reference the FxCop assembly // We don't want to reference the FxCop assembly
@ -170,13 +202,17 @@ namespace ICSharpCode.CodeAnalysis
return v.ToString(); return v.ToString();
} }
public static string[][] GetRuleListInCurrentAppDomain(string fxCopPath) public static string[][] GetRuleListInCurrentAppDomain(string fxCopPath, string[] ruleAssemblies)
{ {
Assembly asm = Assembly.LoadFrom(Path.Combine(fxCopPath, "FxCopCommon.dll")); Assembly asm = Assembly.LoadFrom(Path.Combine(fxCopPath, "FxCopCommon.dll"));
Type fxCopOM = asm.GetType("Microsoft.FxCop.Common.FxCopOM"); Type fxCopOM = asm.GetType("Microsoft.FxCop.Common.FxCopOM");
CallMethod(fxCopOM, "Initialize", BindingFlags.Static, null); CallMethod(fxCopOM, "Initialize", BindingFlags.Static, null);
object engines = fxCopOM.InvokeMember("Engines", BindingFlags.Public | BindingFlags.Static | BindingFlags.GetProperty, null, null, null);
((System.Collections.Specialized.StringCollection)GetProp(engines, "RuleDirectories"))
.AddRange(ruleAssemblies);
object project = asm.CreateInstance("Microsoft.FxCop.Common.Project"); object project = asm.CreateInstance("Microsoft.FxCop.Common.Project");
fxCopOM.InvokeMember("Project", BindingFlags.Public | BindingFlags.Static | BindingFlags.SetProperty, fxCopOM.InvokeMember("Project", BindingFlags.Public | BindingFlags.Static | BindingFlags.SetProperty,
null, null, new object[] { project }); null, null, new object[] { project });

3
src/AddIns/Misc/CodeCoverage/Project/CodeCoverage.addin

@ -66,10 +66,9 @@
</Condition> </Condition>
</Path> </Path>
<Path path = "/SharpDevelop/BackendBindings/ProjectOptions/C#"> <Path path = "/SharpDevelop/BackendBindings/ProjectOptions/AllManaged">
<DialogPanel id = "CodeCoverage" <DialogPanel id = "CodeCoverage"
label = "${res:ICSharpCode.UnitTesting.CodeCoverage}" label = "${res:ICSharpCode.UnitTesting.CodeCoverage}"
insertafter = "Publish"
class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/> class = "ICSharpCode.CodeCoverage.CodeCoverageProjectOptionsPanel"/>
</Path> </Path>
</AddIn> </AddIn>

18
src/Libraries/ICSharpCode.Build.Tasks/Project/FxCop.cs

@ -22,7 +22,7 @@ namespace ICSharpCode.Build.Tasks
string logFile; string logFile;
string realLogFile; string realLogFile;
string inputAssembly; string inputAssembly;
string rules; string[] rules;
string[] ruleAssemblies; string[] ruleAssemblies;
string[] referencePaths; string[] referencePaths;
@ -45,7 +45,7 @@ namespace ICSharpCode.Build.Tasks
} }
} }
public string Rules { public string[] Rules {
get { get {
return rules; return rules;
} }
@ -81,7 +81,7 @@ namespace ICSharpCode.Build.Tasks
public override bool Execute() public override bool Execute()
{ {
if (string.IsNullOrEmpty(ToolPath) || !File.Exists(GenerateFullPathToTool())) { if (string.IsNullOrEmpty(ToolPath)) {
string path = FindFxCopPath(); string path = FindFxCopPath();
Log.LogMessage(MessageImportance.High, "Running Code Analysis..."); Log.LogMessage(MessageImportance.High, "Running Code Analysis...");
if (path != null) { if (path != null) {
@ -96,7 +96,9 @@ namespace ICSharpCode.Build.Tasks
bool result = base.Execute(); bool result = base.Execute();
if (File.Exists(realLogFile)) { if (File.Exists(realLogFile)) {
try { try {
#if DEBUG
Console.WriteLine(File.ReadAllText(realLogFile)); Console.WriteLine(File.ReadAllText(realLogFile));
#endif
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
doc.Load(realLogFile); doc.Load(realLogFile);
foreach (XmlNode node in doc.DocumentElement.SelectNodes(".//Exception")) { foreach (XmlNode node in doc.DocumentElement.SelectNodes(".//Exception")) {
@ -256,10 +258,18 @@ namespace ICSharpCode.Build.Tasks
} }
if (ruleAssemblies != null) { if (ruleAssemblies != null) {
foreach (string asm in ruleAssemblies) { foreach (string asm in ruleAssemblies) {
if (asm.StartsWith("\\")) {
AppendSwitch(b, "r", ToolPath + asm);
} else {
AppendSwitch(b, "r", asm); AppendSwitch(b, "r", asm);
} }
} }
AppendSwitch(b, "rid", rules); }
if (rules != null) {
foreach (string rule in rules) {
AppendSwitch(b, "ruleid", rule);
}
}
return b.ToString(); return b.ToString();
} }
} }

2
src/Libraries/ICSharpCode.Build.Tasks/Project/SharpDevelop.CodeAnalysis.targets

@ -6,7 +6,7 @@
<PropertyGroup> <PropertyGroup>
<!-- Define compilation symbols --> <!-- Define compilation symbols -->
<DefineConstants Condition="'$(RunCodeAnalysis)'=='true' and '$(Language)'!='C#' ">$(DefineConstants);CODE_ANALYSIS</DefineConstants> <DefineConstants Condition="'$(RunCodeAnalysis)'=='true' and '$(Language)'!='VB' ">$(DefineConstants);CODE_ANALYSIS</DefineConstants>
<FinalDefineConstants Condition="'$(RunCodeAnalysis)'=='true' and '$(Language)'=='VB' ">$(FinalDefineConstants),CODE_ANALYSIS=1</FinalDefineConstants> <FinalDefineConstants Condition="'$(RunCodeAnalysis)'=='true' and '$(Language)'=='VB' ">$(FinalDefineConstants),CODE_ANALYSIS=1</FinalDefineConstants>
<!-- prepare task properties --> <!-- prepare task properties -->

19
src/Main/Base/Project/Src/Commands/BuildCommands.cs

@ -111,6 +111,14 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
} }
public class BuildProject : AbstractProjectBuildMenuCommand public class BuildProject : AbstractProjectBuildMenuCommand
{ {
IDictionary<string, string> additionalProperties = new SortedList<string, string>();
public IDictionary<string, string> AdditionalProperties {
get {
return additionalProperties;
}
}
public BuildProject() public BuildProject()
{ {
} }
@ -121,7 +129,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void StartBuild() public override void StartBuild()
{ {
this.ProjectToBuild.Build(CallbackMethod); this.ProjectToBuild.Build(CallbackMethod, AdditionalProperties);
} }
public override void AfterBuild() public override void AfterBuild()
@ -132,9 +140,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public class RebuildProject : BuildProject public class RebuildProject : BuildProject
{ {
public RebuildProject() {}
public RebuildProject(IProject targetProject) : base(targetProject) {}
public override void StartBuild() public override void StartBuild()
{ {
this.ProjectToBuild.Rebuild(CallbackMethod); this.ProjectToBuild.Rebuild(CallbackMethod, AdditionalProperties);
} }
} }
@ -142,7 +153,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{ {
public override void StartBuild() public override void StartBuild()
{ {
this.ProjectToBuild.Clean(CallbackMethod); this.ProjectToBuild.Clean(CallbackMethod, null);
} }
} }
@ -150,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
{ {
public override void StartBuild() public override void StartBuild()
{ {
this.ProjectToBuild.Publish(CallbackMethod); this.ProjectToBuild.Publish(CallbackMethod, null);
} }
} }

14
src/Main/Base/Project/Src/Gui/Components/StringListEditor.cs

@ -225,6 +225,17 @@ namespace ICSharpCode.SharpDevelop.Gui
} }
} }
bool autoAddAfterBrowse;
public bool AutoAddAfterBrowse {
get {
return autoAddAfterBrowse;
}
set {
autoAddAfterBrowse = value;
}
}
public string TitleText { public string TitleText {
get { get {
return TitleLabel.Text; return TitleLabel.Text;
@ -277,6 +288,9 @@ namespace ICSharpCode.SharpDevelop.Gui
if (!path.EndsWith("\\") && !path.EndsWith("/")) if (!path.EndsWith("\\") && !path.EndsWith("/"))
path += "\\"; path += "\\";
editTextBox.Text = path; editTextBox.Text = path;
if (autoAddAfterBrowse) {
AddButtonClick(null, null);
}
} }
} }

8
src/Main/Base/Project/Src/Project/AbstractProject.cs

@ -728,19 +728,19 @@ namespace ICSharpCode.SharpDevelop.Project
#endregion #endregion
public virtual void Build(MSBuildEngineCallback callback) public virtual void Build(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
} }
public virtual void Rebuild(MSBuildEngineCallback callback) public virtual void Rebuild(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
} }
public virtual void Clean(MSBuildEngineCallback callback) public virtual void Clean(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
} }
public virtual void Publish(MSBuildEngineCallback callback) public virtual void Publish(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
} }

8
src/Main/Base/Project/Src/Project/IProject.cs

@ -138,9 +138,9 @@ namespace ICSharpCode.SharpDevelop.Project
/// </summary> /// </summary>
ProjectItem CreateProjectItem(string itemType); ProjectItem CreateProjectItem(string itemType);
void Build(MSBuildEngineCallback callback); void Build(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties);
void Rebuild(MSBuildEngineCallback callback); void Rebuild(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties);
void Clean(MSBuildEngineCallback callback); void Clean(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties);
void Publish(MSBuildEngineCallback callback); void Publish(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties);
} }
} }

2
src/Main/Base/Project/Src/Project/MSBuildEngine.cs

@ -330,7 +330,7 @@ namespace ICSharpCode.SharpDevelop.Project
IProjectContent pc = ParserService.GetProjectContent(project); IProjectContent pc = ParserService.GetProjectContent(project);
if (pc != null) { if (pc != null) {
Position pos = pc.GetPosition(memberName); Position pos = pc.GetPosition(memberName);
if (pos != null) { if (pos != null && pos.Cu != null) {
file = pos.Cu.FileName ?? ""; file = pos.Cu.FileName ?? "";
lineNumber = pos.Line; lineNumber = pos.Line;
columnNumber = pos.Column; columnNumber = pos.Column;

27
src/Main/Base/Project/Src/Project/MSBuildProject.cs

@ -405,7 +405,7 @@ namespace ICSharpCode.SharpDevelop.Project
} }
#endregion #endregion
public static void RunMSBuild(string fileName, string target, string configuration, string platform, bool isSingleProject, MSBuildEngineCallback callback) public static void RunMSBuild(string fileName, string target, string configuration, string platform, bool isSingleProject, MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront(); WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
MSBuildEngine engine = new MSBuildEngine(); MSBuildEngine engine = new MSBuildEngine();
@ -415,6 +415,11 @@ namespace ICSharpCode.SharpDevelop.Project
dir += Path.DirectorySeparatorChar; dir += Path.DirectorySeparatorChar;
engine.AdditionalProperties.Add("SolutionDir", dir); engine.AdditionalProperties.Add("SolutionDir", dir);
} }
if (additionalProperties != null) {
foreach (KeyValuePair<string, string> pair in additionalProperties) {
engine.AdditionalProperties.Add(pair.Key, pair.Value);
}
}
engine.Configuration = configuration; engine.Configuration = configuration;
engine.Platform = platform; engine.Platform = platform;
engine.MessageView = TaskService.BuildMessageViewCategory; engine.MessageView = TaskService.BuildMessageViewCategory;
@ -425,30 +430,30 @@ namespace ICSharpCode.SharpDevelop.Project
} }
} }
public void RunMSBuild(string target, MSBuildEngineCallback callback) public void RunMSBuild(string target, MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
RunMSBuild(this.FileName, target, this.Configuration, this.Platform, true, callback); RunMSBuild(this.FileName, target, this.Configuration, this.Platform, true, callback, additionalProperties);
} }
public override void Build(MSBuildEngineCallback callback) public override void Build(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
RunMSBuild("Build", callback); RunMSBuild("Build", callback, additionalProperties);
} }
public override void Rebuild(MSBuildEngineCallback callback) public override void Rebuild(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
RunMSBuild("Rebuild", callback); RunMSBuild("Rebuild", callback, additionalProperties);
} }
public override void Clean(MSBuildEngineCallback callback) public override void Clean(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
RunMSBuild("Clean", callback); RunMSBuild("Clean", callback, additionalProperties);
isDirty = true; isDirty = true;
} }
public override void Publish(MSBuildEngineCallback callback) public override void Publish(MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
RunMSBuild("Publish", callback); RunMSBuild("Publish", callback, additionalProperties);
} }
public override string ToString() public override string ToString()

12
src/Main/Base/Project/Src/Project/Solution/Solution.cs

@ -637,29 +637,29 @@ namespace ICSharpCode.SharpDevelop.Project
} }
#endregion #endregion
public void RunMSBuild(string target, MSBuildEngineCallback callback) public void RunMSBuild(string target, MSBuildEngineCallback callback, IDictionary<string, string> additionalProperties)
{ {
MSBuildProject.RunMSBuild(FileName, target, preferences.ActiveConfiguration, preferences.ActivePlatform, false, callback); MSBuildProject.RunMSBuild(FileName, target, preferences.ActiveConfiguration, preferences.ActivePlatform, false, callback, additionalProperties);
} }
public void Build(MSBuildEngineCallback callback) public void Build(MSBuildEngineCallback callback)
{ {
RunMSBuild(null, callback); RunMSBuild(null, callback, null);
} }
public void Rebuild(MSBuildEngineCallback callback) public void Rebuild(MSBuildEngineCallback callback)
{ {
RunMSBuild("Rebuild", callback); RunMSBuild("Rebuild", callback, null);
} }
public void Clean(MSBuildEngineCallback callback) public void Clean(MSBuildEngineCallback callback)
{ {
RunMSBuild("Clean", callback); RunMSBuild("Clean", callback, null);
} }
public void Publish(MSBuildEngineCallback callback) public void Publish(MSBuildEngineCallback callback)
{ {
RunMSBuild("Publish", callback); RunMSBuild("Publish", callback, null);
} }
} }
} }

2
src/Main/Base/Project/Src/Services/ParserService/DefaultProjectContent.cs

@ -822,7 +822,7 @@ namespace ICSharpCode.Core
if (curClass != null) { if (curClass != null) {
IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp); IMember member = curClass.SearchMember(memberName, LanguageProperties.CSharp);
if (member != null) { if (member != null) {
return new Position(curClass.CompilationUnit, member.Region.BeginLine, member.Region.BeginColumn); return new Position(member.DeclaringType.CompilationUnit, member.Region.BeginLine, member.Region.BeginColumn);
} }
} }
} }

2
src/Main/GlobalAssemblyInfo.template

@ -21,7 +21,7 @@ using System.Reflection;
[assembly: AssemblyCopyright("2000-2006 AlphaSierraPapa")] [assembly: AssemblyCopyright("2000-2006 AlphaSierraPapa")]
[assembly: AssemblyVersion(RevisionClass.Version + "." + RevisionClass.Revision)] [assembly: AssemblyVersion(RevisionClass.Version + "." + RevisionClass.Revision)]
internal class RevisionClass { internal static class RevisionClass {
public const string Version = "2.1.0"; public const string Version = "2.1.0";
public const string Revision = "-INSERTREVISION-"; public const string Revision = "-INSERTREVISION-";
} }

Loading…
Cancel
Save