diff --git a/AddIns/ICSharpCode.SharpDevelop.addin b/AddIns/ICSharpCode.SharpDevelop.addin index 5f925d093e..e08db5d123 100755 --- a/AddIns/ICSharpCode.SharpDevelop.addin +++ b/AddIns/ICSharpCode.SharpDevelop.addin @@ -1252,36 +1252,35 @@ + @@ -2149,4 +2147,10 @@ description = "${res:ICSharpCode.SharpDevelop.Internal.Project.ProjectFile.LogicalName.Description}" /> + + + + diff --git a/SharpDevelop.Tests.sln b/SharpDevelop.Tests.sln index 06bfbd04bb..916a34c09b 100644 --- a/SharpDevelop.Tests.sln +++ b/SharpDevelop.Tests.sln @@ -1,69 +1,69 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.0.0.5676 +# SharpDevelop 4.0.0.5950 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker", "src\Main\ICSharpCode.SharpDevelop.BuildWorker\ICSharpCode.SharpDevelop.BuildWorker.csproj", "{C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom.Tests", "src\Main\ICSharpCode.SharpDevelop.Dom\Tests\ICSharpCode.SharpDevelop.Dom.Tests\ICSharpCode.SharpDevelop.Dom.Tests.csproj", "{7DB80259-24D4-46C3-A024-53FF1987733D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "src\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "src\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Tests", "src\Main\Core\Test\ICSharpCode.Core.Tests.csproj", "{AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "src\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "src\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "src\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "src\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "src\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "src\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Tests", "src\Main\Core\Test\ICSharpCode.Core.Tests.csproj", "{AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "src\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Tests", "src\Main\Base\Test\ICSharpCode.SharpDevelop.Tests.csproj", "{4980B743-B32F-4aba-AABD-45E2CAD3568D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom.Tests", "src\Main\ICSharpCode.SharpDevelop.Dom\Tests\ICSharpCode.SharpDevelop.Dom.Tests\ICSharpCode.SharpDevelop.Dom.Tests.csproj", "{7DB80259-24D4-46C3-A024-53FF1987733D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker", "src\Main\ICSharpCode.SharpDevelop.BuildWorker\ICSharpCode.SharpDevelop.BuildWorker.csproj", "{C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection @@ -72,50 +72,50 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{ ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit.Tests", "src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit.Tests\ICSharpCode.AvalonEdit.Tests.csproj", "{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "src\Libraries\SharpTreeView\ICSharpCode.TreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NRefactory", "NRefactory", "{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}" - ProjectSection(SolutionItems) = postProject - EndProjectSection +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aga.Controls", "src\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "src\Libraries\NRefactory\Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "src\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "src\Libraries\NRefactory\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "src\Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "src\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonDock", "src\Libraries\AvalonDock\AvalonDock.csproj", "{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonDock", "src\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj", "{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NRefactory", "NRefactory", "{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "src\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "src\Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "src\Libraries\NRefactory\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "src\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryTests", "src\Libraries\NRefactory\Test\NRefactoryTests.csproj", "{870115DD-960A-4406-A6B9-600BCDC36A03}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aga.Controls", "src\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "src\Libraries\SharpTreeView\ICSharpCode.TreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit.Tests", "src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit.Tests\ICSharpCode.AvalonEdit.Tests.csproj", "{6222A3A1-83CE-47A3-A4E4-A018F82D44D8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection @@ -124,221 +124,228 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{393278 ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Profiler", "Profiler", "{C4035C32-026F-4158-AF15-113EA1EF1960}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{F355E45F-F54F-4B42-8916-9A633A392789}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.AddIn", "src\AddIns\Analysis\Profiler\Frontend\AddIn\Profiler.AddIn.csproj", "{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "src\AddIns\Analysis\CodeQuality\CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controls", "src\AddIns\Analysis\Profiler\Frontend\Controls\Profiler.Controls.csproj", "{BDA49550-5ED1-4C6B-B648-657B2CACD8E0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "src\AddIns\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}" ProjectSection(ProjectDependencies) = postProject - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controller", "src\AddIns\Analysis\Profiler\Controller\Profiler.Controller.csproj", "{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "{CE498514-D12D-4B6E-AE0E-FEC29BD43748}" ProjectSection(ProjectDependencies) = postProject - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Analysis\Profiler\X64Converter\Profiler.X64Converter.csproj", "{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Tests", "src\AddIns\Analysis\Profiler\Tests\Profiler.Tests\Profiler.Tests.csproj", "{068F9531-5D29-49E0-980E-59982A3A0469}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\Analysis\CodeAnalysis\CodeAnalysis.csproj", "{3EAA45A9-735C-4AC7-A799-947B93EA449D}" ProjectSection(ProjectDependencies) = postProject - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Language Bindings", "Language Bindings", "{E0646C25-36F2-4524-969F-FA621353AB94}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding", "src\AddIns\BackendBindings\Ruby\RubyBinding\Project\RubyBinding.csproj", "{C896FFFF-5B6C-4B0E-B6DF-049865F501B4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "src\AddIns\Analysis\CodeCoverage\Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBinding", "src\AddIns\BackendBindings\CppBinding\CppBinding\CppBinding.csproj", "{70966F84-74C9-4067-A379-0C674A929233}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComponentInspector", "ComponentInspector", "{D599885D-E161-4CCE-A66E-7A40C8C4F4CC}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.AddIn", "src\AddIns\Misc\ComponentInspector\ComponentInspector.AddIn\ComponentInspector.AddIn.csproj", "{869951D5-A0D6-4DC6-9F1D-E6B9A12AC446}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding.Tests", "src\AddIns\BackendBindings\CSharpBinding\Tests\CSharpBinding.Tests.csproj", "{52006F3F-3156-45DE-89D8-C4813694FBA4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.Core", "src\AddIns\Misc\ComponentInspector\ComponentInspector.Core\ComponentInspector.Core.csproj", "{E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding.Tests", "src\AddIns\BackendBindings\VBNetBinding\Test\VBNetBinding.Tests.csproj", "{50A89267-A28B-4DF3-8E62-912E005143B8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector", "src\AddIns\Misc\ComponentInspector\ComponentInspector\ComponentInspector.csproj", "{000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boo", "Boo", "{97B3B514-AB0E-4FE1-89DE-8A945F5112AE}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BooBinding.Tests", "src\AddIns\BackendBindings\Boo\BooBinding\Test\BooBinding.Tests.csproj", "{6FA16499-896F-4C02-BB43-1AF5C6C7C713}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{6022AC51-B658-4C54-97EF-79187AC65B47}" + ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BooBinding", "src\AddIns\BackendBindings\Boo\BooBinding\Project\BooBinding.csproj", "{4AC2D5F1-F671-480C-A075-6BF62B3721B2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter", "src\AddIns\BackendBindings\Boo\NRefactoryToBooConverter\Project\NRefactoryToBooConverter.csproj", "{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter.Tests", "src\AddIns\BackendBindings\Boo\NRefactoryToBooConverter\Test\NRefactoryToBooConverter.Tests.csproj", "{C9DE556D-325C-4544-B29F-16A9EB7C9830}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{CA76F702-5B4E-4918-B8D8-7FF8382434FF}" - ProjectSection(SolutionItems) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "src\AddIns\BackendBindings\Python\PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks.Tests", "src\AddIns\BackendBindings\Python\Python.Build.Tasks\Test\Python.Build.Tasks.Tests.csproj", "{833904AB-3CD4-4071-9B48-5770E44685AA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks", "src\AddIns\BackendBindings\Python\Python.Build.Tasks\Project\Python.Build.Tasks.csproj", "{D332F2D1-2CF1-43B7-903C-844BD5211A7E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "src\AddIns\DisplayBindings\XmlEditor\Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "src\AddIns\BackendBindings\Python\PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IconEditor", "IconEditor", "{0773ED53-08E2-4495-A3BE-CA0B5D413C15}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditorAddIn", "src\AddIns\DisplayBindings\IconEditor\IconEditorAddIn\IconEditorAddIn.csproj", "{DFB936AD-90EE-4B4F-941E-4F4A636F0D92}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILAsmBinding", "src\AddIns\BackendBindings\ILAsmBinding\Project\ILAsmBinding.csproj", "{6E59AF58-F635-459A-9A35-C9AC41C00339}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditor", "src\AddIns\DisplayBindings\IconEditor\IconEditor\IconEditor.csproj", "{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding", "src\AddIns\BackendBindings\WixBinding\Project\WixBinding.csproj", "{E1B288A2-08EE-4318-8BBB-8AB72C69E33E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexEditor", "src\AddIns\DisplayBindings\HexEditor\Project\HexEditor.csproj", "{E618A9CD-A39F-4925-A538-E8A3FEF24E54}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding", "src\AddIns\BackendBindings\CSharpBinding\Project\CSharpBinding.csproj", "{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "src\AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding", "src\AddIns\BackendBindings\VBNetBinding\Project\VBNetBinding.csproj", "{BF38FB72-B380-4196-AF8C-95749D726C61}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "src\AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{CBC6C247-747B-4908-B09A-4D2E0F640B6B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\BackendBindings\XamlBinding\XamlBinding\XamlBinding.csproj", "{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding.Tests", "src\AddIns\BackendBindings\XamlBinding\XamlBinding.Tests\XamlBinding.Tests.csproj", "{F390DA70-1FE1-4715-81A0-389AB010C130}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "src\AddIns\DisplayBindings\XmlEditor\Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding.Tests", "src\AddIns\BackendBindings\WixBinding\Test\WixBinding.Tests.csproj", "{388E7B64-0393-4EB4-A3E3-5C474F141853}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "src\AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharpBinding", "src\AddIns\BackendBindings\FSharpBinding\FSharpBinding.csproj", "{E954F3CB-A446-492F-A664-2B376EBC86E8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{BFA3BF26-33BD-4A65-B84D-C7F30D131668}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Tests", "src\AddIns\Debugger\Debugger.Tests\Debugger.Tests.csproj", "{A4C858C8-51B6-4265-A695-A20FCEBA1D19}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassCanvas", "src\AddIns\DisplayBindings\ClassDiagram\ClassCanvas\ClassCanvas.csproj", "{08F772A1-F0BE-433E-8B37-F6522953DB05}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramAddin", "src\AddIns\DisplayBindings\ClassDiagram\ClassDiagramAddin\ClassDiagramAddin.csproj", "{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "src\AddIns\Debugger\Debugger.AddIn\Debugger.AddIn.csproj", "{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagrams", "src\AddIns\DisplayBindings\ClassDiagram\DiagramRouter\Diagrams.csproj", "{0991423A-DBF6-4C89-B365-A1DF1EB32E42}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C7F29FC2-1B03-4CDD-9E30-400F4765FF04}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRefactoring.Tests", "src\AddIns\Misc\SharpRefactoring\Test\SharpRefactoring.Tests.csproj", "{A4AA51DE-A096-47EC-AA5D-D91457834ECF}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRefactoring", "src\AddIns\Misc\SharpRefactoring\Project\SharpRefactoring.csproj", "{3CA90546-3B4C-4663-9445-C4E9371750A7}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Addin", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Addin\ICSharpCode.Data.Addin.csproj", "{A9F12710-24E4-46D4-832C-6ECB395B9EAD}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace", "src\AddIns\Misc\SearchAndReplace\Project\SearchAndReplace.csproj", "{9196DD8A-B4D4-4780-8742-C5762E547FC2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core\ICSharpCode.Data.Core.csproj", "{B7823AE9-4B43-4859-8796-2EBDC116FBB8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectorAddIn", "src\AddIns\Misc\ReflectorAddIn\ReflectorAddIn\Project\ReflectorAddIn.csproj", "{8AA421C8-D7AF-4957-9F43-5135328ACB24}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core.UI\ICSharpCode.Data.Core.UI.csproj", "{BAD94D6E-4159-4CB6-B991-486F412D9BB6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartPage", "src\AddIns\Misc\StartPage\Project\StartPage.csproj", "{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core\ICSharpCode.Data.EDMDesigner.Core.csproj", "{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "src\AddIns\Misc\AddInManager\Project\AddInManager.csproj", "{F93E52FD-DA66-4CE5-A0CB-BCD902811122}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core.UI\ICSharpCode.Data.EDMDesigner.Core.UI.csproj", "{EEF5E054-4192-4A57-8FBF-E860D808A51D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinScout", "src\AddIns\Misc\AddinScout\Project\AddinScout.csproj", "{4B8F0F98-8BE1-402B-AA8B-C8D548577B38}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.SQLServer\ICSharpCode.Data.SQLServer.csproj", "{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FiletypeRegisterer", "src\AddIns\Misc\FiletypeRegisterer\Project\FiletypeRegisterer.csproj", "{D022A6CE-7438-41E8-AC64-F2DE18EC54C6}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UsageDataCollector", "UsageDataCollector", "{DEFC8584-BEC3-4921-BD0F-40482E450B7B}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector.AddIn", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector.AddIn\UsageDataCollector.AddIn.csproj", "{0008FCE9-9EB4-4E2E-979B-553278E5BBA6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlHelp2", "src\AddIns\Misc\HtmlHelp2\Project\HtmlHelp2.csproj", "{918487B7-2153-4618-BBB3-344DBDDF2A2A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector\UsageDataCollector.csproj", "{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HtmlHelp2JScriptGlobals", "src\AddIns\Misc\HtmlHelp2\JScriptGlobals\HtmlHelp2JScriptGlobals.vbproj", "{E54A5AD2-418D-4A85-BA5E-CD803DE38715}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace.Tests", "src\AddIns\Misc\SearchAndReplace\Test\SearchAndReplace.Tests.csproj", "{A569DCC1-C608-45FD-B770-4F79335EF154}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeAddIn", "src\AddIns\Misc\PInvokeAddIn\Project\PInvokeAddIn.csproj", "{5EEB99CF-EA2B-4733-80A6-CE9192D68170}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit.Tests", "src\AddIns\Misc\ResourceToolkit\Test\ResourceToolkit.Tests.csproj", "{DD9AE6A5-2B9D-443A-BC71-38BE578C36BD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegExpTk", "src\AddIns\Misc\RegExpTk\Project\RegExpTk.csproj", "{64A3E5E6-90BF-47F6-94DF-68C94B62C817}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "src\AddIns\Misc\SubversionAddIn\Project\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection @@ -348,221 +355,223 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit", "src\AddI {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "src\AddIns\Misc\SubversionAddIn\Project\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegExpTk", "src\AddIns\Misc\RegExpTk\Project\RegExpTk.csproj", "{64A3E5E6-90BF-47F6-94DF-68C94B62C817}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit.Tests", "src\AddIns\Misc\ResourceToolkit\Test\ResourceToolkit.Tests.csproj", "{DD9AE6A5-2B9D-443A-BC71-38BE578C36BD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeAddIn", "src\AddIns\Misc\PInvokeAddIn\Project\PInvokeAddIn.csproj", "{5EEB99CF-EA2B-4733-80A6-CE9192D68170}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace.Tests", "src\AddIns\Misc\SearchAndReplace\Test\SearchAndReplace.Tests.csproj", "{A569DCC1-C608-45FD-B770-4F79335EF154}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FiletypeRegisterer", "src\AddIns\Misc\FiletypeRegisterer\Project\FiletypeRegisterer.csproj", "{D022A6CE-7438-41E8-AC64-F2DE18EC54C6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UsageDataCollector", "UsageDataCollector", "{DEFC8584-BEC3-4921-BD0F-40482E450B7B}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinScout", "src\AddIns\Misc\AddinScout\Project\AddinScout.csproj", "{4B8F0F98-8BE1-402B-AA8B-C8D548577B38}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector\UsageDataCollector.csproj", "{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "src\AddIns\Misc\AddInManager\Project\AddInManager.csproj", "{F93E52FD-DA66-4CE5-A0CB-BCD902811122}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector.AddIn", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector.AddIn\UsageDataCollector.AddIn.csproj", "{0008FCE9-9EB4-4E2E-979B-553278E5BBA6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartPage", "src\AddIns\Misc\StartPage\Project\StartPage.csproj", "{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectorAddIn", "src\AddIns\Misc\ReflectorAddIn\ReflectorAddIn\Project\ReflectorAddIn.csproj", "{8AA421C8-D7AF-4957-9F43-5135328ACB24}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C7F29FC2-1B03-4CDD-9E30-400F4765FF04}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace", "src\AddIns\Misc\SearchAndReplace\Project\SearchAndReplace.csproj", "{9196DD8A-B4D4-4780-8742-C5762E547FC2}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.SQLServer\ICSharpCode.Data.SQLServer.csproj", "{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRefactoring", "src\AddIns\Misc\SharpRefactoring\Project\SharpRefactoring.csproj", "{3CA90546-3B4C-4663-9445-C4E9371750A7}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core.UI\ICSharpCode.Data.EDMDesigner.Core.UI.csproj", "{EEF5E054-4192-4A57-8FBF-E860D808A51D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRefactoring.Tests", "src\AddIns\Misc\SharpRefactoring\Test\SharpRefactoring.Tests.csproj", "{A4AA51DE-A096-47EC-AA5D-D91457834ECF}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core\ICSharpCode.Data.EDMDesigner.Core.csproj", "{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelpViewer", "src\AddIns\Misc\HelpViewer\HelpViewer.csproj", "{80F76D10-0B44-4D55-B4BD-DAEB5464090C}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core.UI\ICSharpCode.Data.Core.UI.csproj", "{BAD94D6E-4159-4CB6-B991-486F412D9BB6}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "src\AddIns\Debugger\Debugger.AddIn\Debugger.AddIn.csproj", "{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core\ICSharpCode.Data.Core.csproj", "{B7823AE9-4B43-4859-8796-2EBDC116FBB8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Addin", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Addin\ICSharpCode.Data.Addin.csproj", "{A9F12710-24E4-46D4-832C-6ECB395B9EAD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Tests", "src\AddIns\Debugger\Debugger.Tests\Debugger.Tests.csproj", "{A4C858C8-51B6-4265-A695-A20FCEBA1D19}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{BFA3BF26-33BD-4A65-B84D-C7F30D131668}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Language Bindings", "Language Bindings", "{E0646C25-36F2-4524-969F-FA621353AB94}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagrams", "src\AddIns\DisplayBindings\ClassDiagram\DiagramRouter\Diagrams.csproj", "{0991423A-DBF6-4C89-B365-A1DF1EB32E42}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharpBinding", "src\AddIns\BackendBindings\FSharpBinding\FSharpBinding.csproj", "{E954F3CB-A446-492F-A664-2B376EBC86E8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramAddin", "src\AddIns\DisplayBindings\ClassDiagram\ClassDiagramAddin\ClassDiagramAddin.csproj", "{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding.Tests", "src\AddIns\BackendBindings\WixBinding\Test\WixBinding.Tests.csproj", "{388E7B64-0393-4EB4-A3E3-5C474F141853}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassCanvas", "src\AddIns\DisplayBindings\ClassDiagram\ClassCanvas\ClassCanvas.csproj", "{08F772A1-F0BE-433E-8B37-F6522953DB05}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding.Tests", "src\AddIns\BackendBindings\XamlBinding\XamlBinding.Tests\XamlBinding.Tests.csproj", "{F390DA70-1FE1-4715-81A0-389AB010C130}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "src\AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\BackendBindings\XamlBinding\XamlBinding\XamlBinding.csproj", "{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "src\AddIns\DisplayBindings\XmlEditor\Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding", "src\AddIns\BackendBindings\VBNetBinding\Project\VBNetBinding.csproj", "{BF38FB72-B380-4196-AF8C-95749D726C61}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding", "src\AddIns\BackendBindings\CSharpBinding\Project\CSharpBinding.csproj", "{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "src\AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{CBC6C247-747B-4908-B09A-4D2E0F640B6B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding", "src\AddIns\BackendBindings\WixBinding\Project\WixBinding.csproj", "{E1B288A2-08EE-4318-8BBB-8AB72C69E33E}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "src\AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILAsmBinding", "src\AddIns\BackendBindings\ILAsmBinding\Project\ILAsmBinding.csproj", "{6E59AF58-F635-459A-9A35-C9AC41C00339}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexEditor", "src\AddIns\DisplayBindings\HexEditor\Project\HexEditor.csproj", "{E618A9CD-A39F-4925-A538-E8A3FEF24E54}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{CA76F702-5B4E-4918-B8D8-7FF8382434FF}" + ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IconEditor", "IconEditor", "{0773ED53-08E2-4495-A3BE-CA0B5D413C15}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "src\AddIns\BackendBindings\Python\PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditor", "src\AddIns\DisplayBindings\IconEditor\IconEditor\IconEditor.csproj", "{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks", "src\AddIns\BackendBindings\Python\Python.Build.Tasks\Project\Python.Build.Tasks.csproj", "{D332F2D1-2CF1-43B7-903C-844BD5211A7E}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditorAddIn", "src\AddIns\DisplayBindings\IconEditor\IconEditorAddIn\IconEditorAddIn.csproj", "{DFB936AD-90EE-4B4F-941E-4F4A636F0D92}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks.Tests", "src\AddIns\BackendBindings\Python\Python.Build.Tasks\Test\Python.Build.Tasks.Tests.csproj", "{833904AB-3CD4-4071-9B48-5770E44685AA}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor.Tests", "src\AddIns\DisplayBindings\XmlEditor\Test\XmlEditor.Tests.csproj", "{FC0FE702-A87D-4D70-A9B6-1ECCD611125F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "src\AddIns\BackendBindings\Python\PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{6022AC51-B658-4C54-97EF-79187AC65B47}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boo", "Boo", "{97B3B514-AB0E-4FE1-89DE-8A945F5112AE}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter.Tests", "src\AddIns\BackendBindings\Boo\NRefactoryToBooConverter\Test\NRefactoryToBooConverter.Tests.csproj", "{C9DE556D-325C-4544-B29F-16A9EB7C9830}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter", "src\AddIns\BackendBindings\Boo\NRefactoryToBooConverter\Project\NRefactoryToBooConverter.csproj", "{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BooBinding", "src\AddIns\BackendBindings\Boo\BooBinding\Project\BooBinding.csproj", "{4AC2D5F1-F671-480C-A075-6BF62B3721B2}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BooBinding.Tests", "src\AddIns\BackendBindings\Boo\BooBinding\Test\BooBinding.Tests.csproj", "{6FA16499-896F-4C02-BB43-1AF5C6C7C713}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding.Tests", "src\AddIns\BackendBindings\VBNetBinding\Test\VBNetBinding.Tests.csproj", "{50A89267-A28B-4DF3-8E62-912E005143B8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComponentInspector", "ComponentInspector", "{D599885D-E161-4CCE-A66E-7A40C8C4F4CC}" - ProjectSection(SolutionItems) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector", "src\AddIns\Misc\ComponentInspector\ComponentInspector\ComponentInspector.csproj", "{000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding.Tests", "src\AddIns\BackendBindings\CSharpBinding\Tests\CSharpBinding.Tests.csproj", "{52006F3F-3156-45DE-89D8-C4813694FBA4}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.Core", "src\AddIns\Misc\ComponentInspector\ComponentInspector.Core\ComponentInspector.Core.csproj", "{E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBinding", "src\AddIns\BackendBindings\CppBinding\CppBinding\CppBinding.csproj", "{70966F84-74C9-4067-A379-0C674A929233}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.AddIn", "src\AddIns\Misc\ComponentInspector\ComponentInspector.AddIn\ComponentInspector.AddIn.csproj", "{869951D5-A0D6-4DC6-9F1D-E6B9A12AC446}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding", "src\AddIns\BackendBindings\Ruby\RubyBinding\Project\RubyBinding.csproj", "{C896FFFF-5B6C-4B0E-B6DF-049865F501B4}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{F355E45F-F54F-4B42-8916-9A633A392789}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Profiler", "Profiler", "{C4035C32-026F-4158-AF15-113EA1EF1960}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "src\AddIns\Analysis\CodeCoverage\Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Tests", "src\AddIns\Analysis\Profiler\Tests\Profiler.Tests\Profiler.Tests.csproj", "{068F9531-5D29-49E0-980E-59982A3A0469}" ProjectSection(ProjectDependencies) = postProject + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\Analysis\CodeAnalysis\CodeAnalysis.csproj", "{3EAA45A9-735C-4AC7-A799-947B93EA449D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Analysis\Profiler\X64Converter\Profiler.X64Converter.csproj", "{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controller", "src\AddIns\Analysis\Profiler\Controller\Profiler.Controller.csproj", "{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F}" ProjectSection(ProjectDependencies) = postProject + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "{CE498514-D12D-4B6E-AE0E-FEC29BD43748}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controls", "src\AddIns\Analysis\Profiler\Frontend\Controls\Profiler.Controls.csproj", "{BDA49550-5ED1-4C6B-B648-657B2CACD8E0}" ProjectSection(ProjectDependencies) = postProject + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "src\AddIns\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.AddIn", "src\AddIns\Analysis\Profiler\Frontend\AddIn\Profiler.AddIn.csproj", "{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} EndProjectSection EndProject Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}" @@ -575,6 +584,8 @@ Global Release|Win32 = Release|Win32 Debug|x86 = Debug|x86 Release|x86 = Release|x86 + Debug|Debug = Debug|Debug + Release|Debug = Release|Debug EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU @@ -701,14 +712,6 @@ Global {D022A6CE-7438-41E8-AC64-F2DE18EC54C6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D022A6CE-7438-41E8-AC64-F2DE18EC54C6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D022A6CE-7438-41E8-AC64-F2DE18EC54C6}.Release|Any CPU.Build.0 = Release|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Release|Any CPU.Build.0 = Release|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Release|Any CPU.Build.0 = Release|Any CPU {5EEB99CF-EA2B-4733-80A6-CE9192D68170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5EEB99CF-EA2B-4733-80A6-CE9192D68170}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EEB99CF-EA2B-4733-80A6-CE9192D68170}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -1025,126 +1028,154 @@ Global {B5F54272-49F0-40DB-845A-8D837875D3BA}.Release|Win32.ActiveCfg = Release|x86 {B5F54272-49F0-40DB-845A-8D837875D3BA}.Release|x86.Build.0 = Release|x86 {B5F54272-49F0-40DB-845A-8D837875D3BA}.Release|x86.ActiveCfg = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Any CPU.Build.0 = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Any CPU.ActiveCfg = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Win32.Build.0 = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Win32.ActiveCfg = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|x86.Build.0 = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|x86.ActiveCfg = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Any CPU.Build.0 = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Any CPU.ActiveCfg = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Win32.Build.0 = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Win32.ActiveCfg = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|x86.Build.0 = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|x86.ActiveCfg = Release|x86 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.Build.0 = Debug|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.ActiveCfg = Debug|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Win32.Build.0 = Debug|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Win32.ActiveCfg = Debug|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|x86.Build.0 = Debug|x86 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|x86.ActiveCfg = Debug|x86 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.Build.0 = Release|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.ActiveCfg = Release|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Win32.Build.0 = Release|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Win32.ActiveCfg = Release|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|x86.Build.0 = Release|x86 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|x86.ActiveCfg = Release|x86 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Debug.Build.0 = Debug|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Debug.ActiveCfg = Debug|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Debug.Build.0 = Release|Debug + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Debug.ActiveCfg = Release|Debug EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {4980B743-B32F-4aba-AABD-45E2CAD3568D} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {7DB80259-24D4-46C3-A024-53FF1987733D} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {B5F54272-49F0-40DB-845A-8D837875D3BA} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {DDE2A481-8271-4EAC-A330-8FA6A38D13D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {E73BB233-D88B-44A7-A98F-D71EE158381D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {2FF700C2-A38A-48BD-A637-8CAFD4FE6237} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {7DB80259-24D4-46C3-A024-53FF1987733D} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {4980B743-B32F-4aba-AABD-45E2CAD3568D} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {6222A3A1-83CE-47A3-A4E4-A018F82D44D8} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} - {B22522AA-B5BF-4A58-AC6D-D4B45805521F} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} + {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {2FF700C2-A38A-48BD-A637-8CAFD4FE6237} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {E73BB233-D88B-44A7-A98F-D71EE158381D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {DDE2A481-8271-4EAC-A330-8FA6A38D13D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} {870115DD-960A-4406-A6B9-600BCDC36A03} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} - {F355E45F-F54F-4B42-8916-9A633A392789} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {E0646C25-36F2-4524-969F-FA621353AB94} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {B22522AA-B5BF-4A58-AC6D-D4B45805521F} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} {C4035C32-026F-4158-AF15-113EA1EF1960} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {068F9531-5D29-49E0-980E-59982A3A0469} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {BDA49550-5ED1-4C6B-B648-657B2CACD8E0} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94} - {388E7B64-0393-4EB4-A3E3-5C474F141853} = {E0646C25-36F2-4524-969F-FA621353AB94} - {F390DA70-1FE1-4715-81A0-389AB010C130} = {E0646C25-36F2-4524-969F-FA621353AB94} - {7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94} - {BF38FB72-B380-4196-AF8C-95749D726C61} = {E0646C25-36F2-4524-969F-FA621353AB94} - {1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94} - {E1B288A2-08EE-4318-8BBB-8AB72C69E33E} = {E0646C25-36F2-4524-969F-FA621353AB94} - {6E59AF58-F635-459A-9A35-C9AC41C00339} = {E0646C25-36F2-4524-969F-FA621353AB94} - {CA76F702-5B4E-4918-B8D8-7FF8382434FF} = {E0646C25-36F2-4524-969F-FA621353AB94} - {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} = {E0646C25-36F2-4524-969F-FA621353AB94} - {50A89267-A28B-4DF3-8E62-912E005143B8} = {E0646C25-36F2-4524-969F-FA621353AB94} - {52006F3F-3156-45DE-89D8-C4813694FBA4} = {E0646C25-36F2-4524-969F-FA621353AB94} - {70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94} - {C896FFFF-5B6C-4B0E-B6DF-049865F501B4} = {E0646C25-36F2-4524-969F-FA621353AB94} - {C9DE556D-325C-4544-B29F-16A9EB7C9830} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} - {DBCF20A1-BA13-4582-BFA9-74DE4D987B73} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} - {4AC2D5F1-F671-480C-A075-6BF62B3721B2} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} - {6FA16499-896F-4C02-BB43-1AF5C6C7C713} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} - {8D732610-8FC6-43BA-94C9-7126FD7FE361} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} - {D332F2D1-2CF1-43B7-903C-844BD5211A7E} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} - {833904AB-3CD4-4071-9B48-5770E44685AA} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} - {23B517C9-1ECC-4419-A13F-0B7136D085CB} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} - {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} - {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} - {A4C858C8-51B6-4265-A695-A20FCEBA1D19} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} - {DEFC8584-BEC3-4921-BD0F-40482E450B7B} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {A569DCC1-C608-45FD-B770-4F79335EF154} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {DD9AE6A5-2B9D-443A-BC71-38BE578C36BD} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {461606BD-E824-4D0A-8CBA-01810B1F5E02} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {5EEB99CF-EA2B-4733-80A6-CE9192D68170} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {E54A5AD2-418D-4A85-BA5E-CD803DE38715} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {918487B7-2153-4618-BBB3-344DBDDF2A2A} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {4B8F0F98-8BE1-402B-AA8B-C8D548577B38} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {F93E52FD-DA66-4CE5-A0CB-BCD902811122} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {8AA421C8-D7AF-4957-9F43-5135328ACB24} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {3CA90546-3B4C-4663-9445-C4E9371750A7} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {A4AA51DE-A096-47EC-AA5D-D91457834ECF} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} - {6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} - {6022AC51-B658-4C54-97EF-79187AC65B47} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {FC0FE702-A87D-4D70-A9B6-1ECCD611125F} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {0773ED53-08E2-4495-A3BE-CA0B5D413C15} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {BFA3BF26-33BD-4A65-B84D-C7F30D131668} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {E0646C25-36F2-4524-969F-FA621353AB94} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {F355E45F-F54F-4B42-8916-9A633A392789} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B} = {F355E45F-F54F-4B42-8916-9A633A392789} + {1F261725-6318-4434-A1B1-6C70CE4CD324} = {F355E45F-F54F-4B42-8916-9A633A392789} + {3EAA45A9-735C-4AC7-A799-947B93EA449D} = {F355E45F-F54F-4B42-8916-9A633A392789} + {08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {F355E45F-F54F-4B42-8916-9A633A392789} + {CE498514-D12D-4B6E-AE0E-FEC29BD43748} = {F355E45F-F54F-4B42-8916-9A633A392789} + {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181} = {F355E45F-F54F-4B42-8916-9A633A392789} + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3} = {F355E45F-F54F-4B42-8916-9A633A392789} + {000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} + {E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} + {869951D5-A0D6-4DC6-9F1D-E6B9A12AC446} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {EEF5E054-4192-4A57-8FBF-E860D808A51D} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {08F772A1-F0BE-433E-8B37-F6522953DB05} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} - {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} - {0991423A-DBF6-4C89-B365-A1DF1EB32E42} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} - {DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} - {DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} - {88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {943DBBB3-E84E-4CF4-917C-C05AFA8743C1} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {78CC29AC-CC79-4355-B1F2-97936DF198AC} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {BFA3BF26-33BD-4A65-B84D-C7F30D131668} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {0773ED53-08E2-4495-A3BE-CA0B5D413C15} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {FC0FE702-A87D-4D70-A9B6-1ECCD611125F} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {6022AC51-B658-4C54-97EF-79187AC65B47} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {869951D5-A0D6-4DC6-9F1D-E6B9A12AC446} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} - {E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} - {000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} - {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181} = {F355E45F-F54F-4B42-8916-9A633A392789} - {CE498514-D12D-4B6E-AE0E-FEC29BD43748} = {F355E45F-F54F-4B42-8916-9A633A392789} - {08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {F355E45F-F54F-4B42-8916-9A633A392789} - {3EAA45A9-735C-4AC7-A799-947B93EA449D} = {F355E45F-F54F-4B42-8916-9A633A392789} - {1F261725-6318-4434-A1B1-6C70CE4CD324} = {F355E45F-F54F-4B42-8916-9A633A392789} - {A5C0E8F8-9D04-46ED-91D6-1DEF1575313B} = {F355E45F-F54F-4B42-8916-9A633A392789} + {9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {78CC29AC-CC79-4355-B1F2-97936DF198AC} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {943DBBB3-E84E-4CF4-917C-C05AFA8743C1} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} + {DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} + {08F772A1-F0BE-433E-8B37-F6522953DB05} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} + {AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {EEF5E054-4192-4A57-8FBF-E860D808A51D} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {A4AA51DE-A096-47EC-AA5D-D91457834ECF} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {3CA90546-3B4C-4663-9445-C4E9371750A7} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {8AA421C8-D7AF-4957-9F43-5135328ACB24} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {F93E52FD-DA66-4CE5-A0CB-BCD902811122} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {4B8F0F98-8BE1-402B-AA8B-C8D548577B38} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {5EEB99CF-EA2B-4733-80A6-CE9192D68170} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {461606BD-E824-4D0A-8CBA-01810B1F5E02} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {DD9AE6A5-2B9D-443A-BC71-38BE578C36BD} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {A569DCC1-C608-45FD-B770-4F79335EF154} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {DEFC8584-BEC3-4921-BD0F-40482E450B7B} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} + {0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} + {A4C858C8-51B6-4265-A695-A20FCEBA1D19} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} + {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} + {C896FFFF-5B6C-4B0E-B6DF-049865F501B4} = {E0646C25-36F2-4524-969F-FA621353AB94} + {70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94} + {52006F3F-3156-45DE-89D8-C4813694FBA4} = {E0646C25-36F2-4524-969F-FA621353AB94} + {50A89267-A28B-4DF3-8E62-912E005143B8} = {E0646C25-36F2-4524-969F-FA621353AB94} + {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} = {E0646C25-36F2-4524-969F-FA621353AB94} + {CA76F702-5B4E-4918-B8D8-7FF8382434FF} = {E0646C25-36F2-4524-969F-FA621353AB94} + {6E59AF58-F635-459A-9A35-C9AC41C00339} = {E0646C25-36F2-4524-969F-FA621353AB94} + {E1B288A2-08EE-4318-8BBB-8AB72C69E33E} = {E0646C25-36F2-4524-969F-FA621353AB94} + {1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94} + {BF38FB72-B380-4196-AF8C-95749D726C61} = {E0646C25-36F2-4524-969F-FA621353AB94} + {7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94} + {F390DA70-1FE1-4715-81A0-389AB010C130} = {E0646C25-36F2-4524-969F-FA621353AB94} + {388E7B64-0393-4EB4-A3E3-5C474F141853} = {E0646C25-36F2-4524-969F-FA621353AB94} + {E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94} + {23B517C9-1ECC-4419-A13F-0B7136D085CB} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} + {833904AB-3CD4-4071-9B48-5770E44685AA} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} + {D332F2D1-2CF1-43B7-903C-844BD5211A7E} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} + {8D732610-8FC6-43BA-94C9-7126FD7FE361} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} + {6FA16499-896F-4C02-BB43-1AF5C6C7C713} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} + {4AC2D5F1-F671-480C-A075-6BF62B3721B2} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} + {DBCF20A1-BA13-4582-BFA9-74DE4D987B73} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} + {C9DE556D-325C-4544-B29F-16A9EB7C9830} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} + {D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {BDA49550-5ED1-4C6B-B648-657B2CACD8E0} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {068F9531-5D29-49E0-980E-59982A3A0469} = {C4035C32-026F-4158-AF15-113EA1EF1960} EndGlobalSection EndGlobal diff --git a/SharpDevelop.sln b/SharpDevelop.sln index d08fab6e18..37f4eacbf1 100644 --- a/SharpDevelop.sln +++ b/SharpDevelop.sln @@ -1,59 +1,59 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.0.0.5779 +# SharpDevelop 4.0.0.5826 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker", "src\Main\ICSharpCode.SharpDevelop.BuildWorker\ICSharpCode.SharpDevelop.BuildWorker.csproj", "{C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Tests", "src\Main\Core\Test\ICSharpCode.Core.Tests.csproj", "{AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "src\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "src\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "src\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "src\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "src\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.WinForms", "src\Main\ICSharpCode.Core.WinForms\ICSharpCode.Core.WinForms.csproj", "{857CA1A3-FC88-4BE0-AB6A-D1EE772AB288}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Sda", "src\Main\ICSharpCode.SharpDevelop.Sda\ICSharpCode.SharpDevelop.Sda.csproj", "{80318B5F-A25D-45AB-8A95-EF31D2370A4C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Presentation", "src\Main\ICSharpCode.Core.Presentation\ICSharpCode.Core.Presentation.csproj", "{7E4A7172-7FF5-48D0-B719-7CD959DD1AC9}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "src\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "src\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core.Tests", "src\Main\Core\Test\ICSharpCode.Core.Tests.csproj", "{AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "src\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker", "src\Main\ICSharpCode.SharpDevelop.BuildWorker\ICSharpCode.SharpDevelop.BuildWorker.csproj", "{C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartUp", "src\Main\StartUp\Project\StartUp.csproj", "{1152B71B-3C05-4598-B20D-823B5D40559E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.BuildWorker35", "src\Main\ICSharpCode.SharpDevelop.BuildWorker35\ICSharpCode.SharpDevelop.BuildWorker35.csproj", "{B5F54272-49F0-40DB-845A-8D837875D3BA}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection @@ -62,40 +62,40 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{ ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NRefactory", "NRefactory", "{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "src\Libraries\SharpTreeView\ICSharpCode.TreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "src\Libraries\NRefactory\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aga.Controls", "src\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "src\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "src\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "src\Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonDock", "src\Libraries\AvalonDock\AvalonDock.csproj", "{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "src\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Build.Tasks", "src\Libraries\ICSharpCode.Build.Tasks\Project\ICSharpCode.Build.Tasks.csproj", "{4139CCF6-FB49-4A9D-B2CF-331E9EA3198D}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonDock", "src\Libraries\AvalonDock\AvalonDock\AvalonDock.csproj", "{2FF700C2-A38A-48BD-A637-8CAFD4FE6237}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NRefactory", "NRefactory", "{E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865}" + ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "src\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "src\Libraries\NRefactory\Project\NRefactory.csproj", "{3A9AE6AA-BC07-4A2F-972C-581E3AE2F195}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aga.Controls", "src\Libraries\TreeViewAdv\Aga.Controls\Aga.Controls.csproj", "{E73BB233-D88B-44A7-A98F-D71EE158381D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "src\Libraries\SharpTreeView\ICSharpCode.TreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryASTGenerator", "src\Libraries\NRefactory\NRefactoryASTGenerator\NRefactoryASTGenerator.csproj", "{B22522AA-B5BF-4A58-AC6D-D4B45805521F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection @@ -104,362 +104,368 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AddIns", "AddIns", "{393278 ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Profiler", "Profiler", "{C4035C32-026F-4158-AF15-113EA1EF1960}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{F355E45F-F54F-4B42-8916-9A633A392789}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.AddIn", "src\AddIns\Analysis\Profiler\Frontend\AddIn\Profiler.AddIn.csproj", "{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controls", "src\AddIns\Analysis\Profiler\Frontend\Controls\Profiler.Controls.csproj", "{BDA49550-5ED1-4C6B-B648-657B2CACD8E0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "{CE498514-D12D-4B6E-AE0E-FEC29BD43748}" ProjectSection(ProjectDependencies) = postProject - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controller", "src\AddIns\Analysis\Profiler\Controller\Profiler.Controller.csproj", "{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}" ProjectSection(ProjectDependencies) = postProject - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Analysis\Profiler\X64Converter\Profiler.X64Converter.csproj", "{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\Analysis\CodeAnalysis\CodeAnalysis.csproj", "{3EAA45A9-735C-4AC7-A799-947B93EA449D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Language Bindings", "Language Bindings", "{E0646C25-36F2-4524-969F-FA621353AB94}" - ProjectSection(SolutionItems) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding", "src\AddIns\BackendBindings\Ruby\RubyBinding\Project\RubyBinding.csproj", "{C896FFFF-5B6C-4B0E-B6DF-049865F501B4}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "src\AddIns\Analysis\CodeQuality\CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBinding", "src\AddIns\BackendBindings\CppBinding\CppBinding\CppBinding.csproj", "{70966F84-74C9-4067-A379-0C674A929233}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boo", "Boo", "{97B3B514-AB0E-4FE1-89DE-8A945F5112AE}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComponentInspector", "ComponentInspector", "{D599885D-E161-4CCE-A66E-7A40C8C4F4CC}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BooBinding", "src\AddIns\BackendBindings\Boo\BooBinding\Project\BooBinding.csproj", "{4AC2D5F1-F671-480C-A075-6BF62B3721B2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.AddIn", "src\AddIns\Misc\ComponentInspector\ComponentInspector.AddIn\ComponentInspector.AddIn.csproj", "{869951D5-A0D6-4DC6-9F1D-E6B9A12AC446}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter", "src\AddIns\BackendBindings\Boo\NRefactoryToBooConverter\Project\NRefactoryToBooConverter.csproj", "{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.Core", "src\AddIns\Misc\ComponentInspector\ComponentInspector.Core\ComponentInspector.Core.csproj", "{E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{CA76F702-5B4E-4918-B8D8-7FF8382434FF}" - ProjectSection(SolutionItems) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks", "src\AddIns\BackendBindings\Python\Python.Build.Tasks\Project\Python.Build.Tasks.csproj", "{D332F2D1-2CF1-43B7-903C-844BD5211A7E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector", "src\AddIns\Misc\ComponentInspector\ComponentInspector\ComponentInspector.csproj", "{000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "src\AddIns\BackendBindings\Python\PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" + ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILAsmBinding", "src\AddIns\BackendBindings\ILAsmBinding\Project\ILAsmBinding.csproj", "{6E59AF58-F635-459A-9A35-C9AC41C00339}" - ProjectSection(ProjectDependencies) = postProject - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{6022AC51-B658-4C54-97EF-79187AC65B47}" + ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding", "src\AddIns\BackendBindings\WixBinding\Project\WixBinding.csproj", "{E1B288A2-08EE-4318-8BBB-8AB72C69E33E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding", "src\AddIns\BackendBindings\CSharpBinding\Project\CSharpBinding.csproj", "{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding", "src\AddIns\BackendBindings\VBNetBinding\Project\VBNetBinding.csproj", "{BF38FB72-B380-4196-AF8C-95749D726C61}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\BackendBindings\XamlBinding\XamlBinding\XamlBinding.csproj", "{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharpBinding", "src\AddIns\BackendBindings\FSharpBinding\FSharpBinding.csproj", "{E954F3CB-A446-492F-A664-2B376EBC86E8}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IconEditor", "IconEditor", "{0773ED53-08E2-4495-A3BE-CA0B5D413C15}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditorAddIn", "src\AddIns\DisplayBindings\IconEditor\IconEditorAddIn\IconEditorAddIn.csproj", "{DFB936AD-90EE-4B4F-941E-4F4A636F0D92}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "src\AddIns\Debugger\Debugger.AddIn\Debugger.AddIn.csproj", "{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditor", "src\AddIns\DisplayBindings\IconEditor\IconEditor\IconEditor.csproj", "{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}" - ProjectSection(SolutionItems) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRefactoring", "src\AddIns\Misc\SharpRefactoring\Project\SharpRefactoring.csproj", "{3CA90546-3B4C-4663-9445-C4E9371750A7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace", "src\AddIns\Misc\SearchAndReplace\Project\SearchAndReplace.csproj", "{9196DD8A-B4D4-4780-8742-C5762E547FC2}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexEditor", "src\AddIns\DisplayBindings\HexEditor\Project\HexEditor.csproj", "{E618A9CD-A39F-4925-A538-E8A3FEF24E54}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectorAddIn", "src\AddIns\Misc\ReflectorAddIn\ReflectorAddIn\Project\ReflectorAddIn.csproj", "{8AA421C8-D7AF-4957-9F43-5135328ACB24}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "src\AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartPage", "src\AddIns\Misc\StartPage\Project\StartPage.csproj", "{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "src\AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{CBC6C247-747B-4908-B09A-4D2E0F640B6B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "src\AddIns\Misc\AddInManager\Project\AddInManager.csproj", "{F93E52FD-DA66-4CE5-A0CB-BCD902811122}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinScout", "src\AddIns\Misc\AddinScout\Project\AddinScout.csproj", "{4B8F0F98-8BE1-402B-AA8B-C8D548577B38}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "src\AddIns\DisplayBindings\XmlEditor\Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FiletypeRegisterer", "src\AddIns\Misc\FiletypeRegisterer\Project\FiletypeRegisterer.csproj", "{D022A6CE-7438-41E8-AC64-F2DE18EC54C6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "src\AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HtmlHelp2", "src\AddIns\Misc\HtmlHelp2\Project\HtmlHelp2.csproj", "{918487B7-2153-4618-BBB3-344DBDDF2A2A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{BFA3BF26-33BD-4A65-B84D-C7F30D131668}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassCanvas", "src\AddIns\DisplayBindings\ClassDiagram\ClassCanvas\ClassCanvas.csproj", "{08F772A1-F0BE-433E-8B37-F6522953DB05}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HtmlHelp2JScriptGlobals", "src\AddIns\Misc\HtmlHelp2\JScriptGlobals\HtmlHelp2JScriptGlobals.vbproj", "{E54A5AD2-418D-4A85-BA5E-CD803DE38715}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramAddin", "src\AddIns\DisplayBindings\ClassDiagram\ClassDiagramAddin\ClassDiagramAddin.csproj", "{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeAddIn", "src\AddIns\Misc\PInvokeAddIn\Project\PInvokeAddIn.csproj", "{5EEB99CF-EA2B-4733-80A6-CE9192D68170}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagrams", "src\AddIns\DisplayBindings\ClassDiagram\DiagramRouter\Diagrams.csproj", "{0991423A-DBF6-4C89-B365-A1DF1EB32E42}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegExpTk", "src\AddIns\Misc\RegExpTk\Project\RegExpTk.csproj", "{64A3E5E6-90BF-47F6-94DF-68C94B62C817}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C7F29FC2-1B03-4CDD-9E30-400F4765FF04}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Addin", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Addin\ICSharpCode.Data.Addin.csproj", "{A9F12710-24E4-46D4-832C-6ECB395B9EAD}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit", "src\AddIns\Misc\ResourceToolkit\Project\ResourceToolkit.csproj", "{461606BD-E824-4D0A-8CBA-01810B1F5E02}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core\ICSharpCode.Data.Core.csproj", "{B7823AE9-4B43-4859-8796-2EBDC116FBB8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "src\AddIns\Misc\SubversionAddIn\Project\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core.UI\ICSharpCode.Data.Core.UI.csproj", "{BAD94D6E-4159-4CB6-B991-486F412D9BB6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UsageDataCollector", "UsageDataCollector", "{DEFC8584-BEC3-4921-BD0F-40482E450B7B}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core\ICSharpCode.Data.EDMDesigner.Core.csproj", "{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector\UsageDataCollector.csproj", "{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core.UI\ICSharpCode.Data.EDMDesigner.Core.UI.csproj", "{EEF5E054-4192-4A57-8FBF-E860D808A51D}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector.AddIn", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector.AddIn\UsageDataCollector.AddIn.csproj", "{0008FCE9-9EB4-4E2E-979B-553278E5BBA6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.SQLServer\ICSharpCode.Data.SQLServer.csproj", "{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display Bindings", "{11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{F3662720-9EA2-4591-BBC6-97361DCE50A9}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Data", "Data", "{C7F29FC2-1B03-4CDD-9E30-400F4765FF04}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UsageDataCollector", "UsageDataCollector", "{DEFC8584-BEC3-4921-BD0F-40482E450B7B}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.SQLServer\ICSharpCode.Data.SQLServer.csproj", "{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector.AddIn", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector.AddIn\UsageDataCollector.AddIn.csproj", "{0008FCE9-9EB4-4E2E-979B-553278E5BBA6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core.UI\ICSharpCode.Data.EDMDesigner.Core.UI.csproj", "{EEF5E054-4192-4A57-8FBF-E860D808A51D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UsageDataCollector", "src\AddIns\Misc\UsageDataCollector\UsageDataCollector\UsageDataCollector.csproj", "{6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigner.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.EDMDesigner.Core\ICSharpCode.Data.EDMDesigner.Core.csproj", "{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SubversionAddIn", "src\AddIns\Misc\SubversionAddIn\Project\SubversionAddIn.csproj", "{17F4D7E0-6933-4C2E-8714-FD7E98D625D5}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core.UI", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core.UI\ICSharpCode.Data.Core.UI.csproj", "{BAD94D6E-4159-4CB6-B991-486F412D9BB6}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceToolkit", "src\AddIns\Misc\ResourceToolkit\Project\ResourceToolkit.csproj", "{461606BD-E824-4D0A-8CBA-01810B1F5E02}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Core", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Core\ICSharpCode.Data.Core.csproj", "{B7823AE9-4B43-4859-8796-2EBDC116FBB8}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegExpTk", "src\AddIns\Misc\RegExpTk\Project\RegExpTk.csproj", "{64A3E5E6-90BF-47F6-94DF-68C94B62C817}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.Addin", "src\AddIns\DisplayBindings\Data\ICSharpCode.Data.Addin\ICSharpCode.Data.Addin.csproj", "{A9F12710-24E4-46D4-832C-6ECB395B9EAD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PInvokeAddIn", "src\AddIns\Misc\PInvokeAddIn\Project\PInvokeAddIn.csproj", "{5EEB99CF-EA2B-4733-80A6-CE9192D68170}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{BFA3BF26-33BD-4A65-B84D-C7F30D131668}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FiletypeRegisterer", "src\AddIns\Misc\FiletypeRegisterer\Project\FiletypeRegisterer.csproj", "{D022A6CE-7438-41E8-AC64-F2DE18EC54C6}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Diagrams", "src\AddIns\DisplayBindings\ClassDiagram\DiagramRouter\Diagrams.csproj", "{0991423A-DBF6-4C89-B365-A1DF1EB32E42}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddinScout", "src\AddIns\Misc\AddinScout\Project\AddinScout.csproj", "{4B8F0F98-8BE1-402B-AA8B-C8D548577B38}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassDiagramAddin", "src\AddIns\DisplayBindings\ClassDiagram\ClassDiagramAddin\ClassDiagramAddin.csproj", "{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "src\AddIns\Misc\AddInManager\Project\AddInManager.csproj", "{F93E52FD-DA66-4CE5-A0CB-BCD902811122}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassCanvas", "src\AddIns\DisplayBindings\ClassDiagram\ClassCanvas\ClassCanvas.csproj", "{08F772A1-F0BE-433E-8B37-F6522953DB05}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StartPage", "src\AddIns\Misc\StartPage\Project\StartPage.csproj", "{7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "src\AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectorAddIn", "src\AddIns\Misc\ReflectorAddIn\ReflectorAddIn\Project\ReflectorAddIn.csproj", "{8AA421C8-D7AF-4957-9F43-5135328ACB24}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XmlEditor", "src\AddIns\DisplayBindings\XmlEditor\Project\XmlEditor.csproj", "{DCA2703D-250A-463E-A68A-07ED105AE6BD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SearchAndReplace", "src\AddIns\Misc\SearchAndReplace\Project\SearchAndReplace.csproj", "{9196DD8A-B4D4-4780-8742-C5762E547FC2}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "src\AddIns\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpRefactoring", "src\AddIns\Misc\SharpRefactoring\Project\SharpRefactoring.csproj", "{3CA90546-3B4C-4663-9445-C4E9371750A7}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ResourceEditor", "src\AddIns\DisplayBindings\ResourceEditor\Project\ResourceEditor.csproj", "{CBC6C247-747B-4908-B09A-4D2E0F640B6B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelpViewer", "src\AddIns\Misc\HelpViewer\HelpViewer.csproj", "{80F76D10-0B44-4D55-B4BD-DAEB5464090C}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "src\AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.AddIn", "src\AddIns\Debugger\Debugger.AddIn\Debugger.AddIn.csproj", "{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HexEditor", "src\AddIns\DisplayBindings\HexEditor\Project\HexEditor.csproj", "{E618A9CD-A39F-4925-A538-E8A3FEF24E54}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "src\AddIns\Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IconEditor", "IconEditor", "{0773ED53-08E2-4495-A3BE-CA0B5D413C15}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Language Bindings", "Language Bindings", "{E0646C25-36F2-4524-969F-FA621353AB94}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditor", "src\AddIns\DisplayBindings\IconEditor\IconEditor\IconEditor.csproj", "{DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSharpBinding", "src\AddIns\BackendBindings\FSharpBinding\FSharpBinding.csproj", "{E954F3CB-A446-492F-A664-2B376EBC86E8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconEditorAddIn", "src\AddIns\DisplayBindings\IconEditor\IconEditorAddIn\IconEditorAddIn.csproj", "{DFB936AD-90EE-4B4F-941E-4F4A636F0D92}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlBinding", "src\AddIns\BackendBindings\XamlBinding\XamlBinding\XamlBinding.csproj", "{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{6022AC51-B658-4C54-97EF-79187AC65B47}" - ProjectSection(SolutionItems) = postProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VBNetBinding", "src\AddIns\BackendBindings\VBNetBinding\Project\VBNetBinding.csproj", "{BF38FB72-B380-4196-AF8C-95749D726C61}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpBinding", "src\AddIns\BackendBindings\CSharpBinding\Project\CSharpBinding.csproj", "{1F1AC7CD-D154-45BB-8EAF-804CA8055F5A}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WixBinding", "src\AddIns\BackendBindings\WixBinding\Project\WixBinding.csproj", "{E1B288A2-08EE-4318-8BBB-8AB72C69E33E}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILAsmBinding", "src\AddIns\BackendBindings\ILAsmBinding\Project\ILAsmBinding.csproj", "{6E59AF58-F635-459A-9A35-C9AC41C00339}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Python", "Python", "{CA76F702-5B4E-4918-B8D8-7FF8382434FF}" + ProjectSection(SolutionItems) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "src\AddIns\BackendBindings\Python\PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ComponentInspector", "ComponentInspector", "{D599885D-E161-4CCE-A66E-7A40C8C4F4CC}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Build.Tasks", "src\AddIns\BackendBindings\Python\Python.Build.Tasks\Project\Python.Build.Tasks.csproj", "{D332F2D1-2CF1-43B7-903C-844BD5211A7E}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boo", "Boo", "{97B3B514-AB0E-4FE1-89DE-8A945F5112AE}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector", "src\AddIns\Misc\ComponentInspector\ComponentInspector\ComponentInspector.csproj", "{000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryToBooConverter", "src\AddIns\BackendBindings\Boo\NRefactoryToBooConverter\Project\NRefactoryToBooConverter.csproj", "{DBCF20A1-BA13-4582-BFA9-74DE4D987B73}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.Core", "src\AddIns\Misc\ComponentInspector\ComponentInspector.Core\ComponentInspector.Core.csproj", "{E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BooBinding", "src\AddIns\BackendBindings\Boo\BooBinding\Project\BooBinding.csproj", "{4AC2D5F1-F671-480C-A075-6BF62B3721B2}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComponentInspector.AddIn", "src\AddIns\Misc\ComponentInspector\ComponentInspector.AddIn\ComponentInspector.AddIn.csproj", "{869951D5-A0D6-4DC6-9F1D-E6B9A12AC446}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CppBinding", "src\AddIns\BackendBindings\CppBinding\CppBinding\CppBinding.csproj", "{70966F84-74C9-4067-A379-0C674A929233}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{F355E45F-F54F-4B42-8916-9A633A392789}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RubyBinding", "src\AddIns\BackendBindings\Ruby\RubyBinding\Project\RubyBinding.csproj", "{C896FFFF-5B6C-4B0E-B6DF-049865F501B4}" + ProjectSection(ProjectDependencies) = postProject + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Profiler", "Profiler", "{C4035C32-026F-4158-AF15-113EA1EF1960}" ProjectSection(SolutionItems) = postProject EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "src\AddIns\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.X64Converter", "src\AddIns\Analysis\Profiler\X64Converter\Profiler.X64Converter.csproj", "{FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeAnalysis", "src\AddIns\Analysis\CodeAnalysis\CodeAnalysis.csproj", "{3EAA45A9-735C-4AC7-A799-947B93EA449D}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controller", "src\AddIns\Analysis\Profiler\Controller\Profiler.Controller.csproj", "{72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F}" ProjectSection(ProjectDependencies) = postProject + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "src\AddIns\Analysis\CodeCoverage\Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.Controls", "src\AddIns\Analysis\Profiler\Frontend\Controls\Profiler.Controls.csproj", "{BDA49550-5ED1-4C6B-B648-657B2CACD8E0}" ProjectSection(ProjectDependencies) = postProject + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceAnalysis", "src\AddIns\Analysis\SourceAnalysis\SourceAnalysis.csproj", "{CE498514-D12D-4B6E-AE0E-FEC29BD43748}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Profiler.AddIn", "src\AddIns\Analysis\Profiler\Frontend\AddIn\Profiler.AddIn.csproj", "{D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B}" ProjectSection(ProjectDependencies) = postProject {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} EndProjectSection EndProject Project("{00000000-0000-0000-0000-000000000000}") = "Tools", "src\Tools\Tools.build", "{3DF4060F-5EE0-41CF-8096-F27355FD5511}" @@ -598,14 +604,6 @@ Global {D022A6CE-7438-41E8-AC64-F2DE18EC54C6}.Debug|Any CPU.Build.0 = Debug|Any CPU {D022A6CE-7438-41E8-AC64-F2DE18EC54C6}.Release|Any CPU.ActiveCfg = Release|Any CPU {D022A6CE-7438-41E8-AC64-F2DE18EC54C6}.Release|Any CPU.Build.0 = Release|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {918487B7-2153-4618-BBB3-344DBDDF2A2A}.Release|Any CPU.Build.0 = Release|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E54A5AD2-418D-4A85-BA5E-CD803DE38715}.Release|Any CPU.Build.0 = Release|Any CPU {5EEB99CF-EA2B-4733-80A6-CE9192D68170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5EEB99CF-EA2B-4733-80A6-CE9192D68170}.Debug|Any CPU.Build.0 = Debug|Any CPU {5EEB99CF-EA2B-4733-80A6-CE9192D68170}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -686,6 +684,10 @@ Global {3EAA45A9-735C-4AC7-A799-947B93EA449D}.Debug|Any CPU.Build.0 = Debug|Any CPU {3EAA45A9-735C-4AC7-A799-947B93EA449D}.Release|Any CPU.ActiveCfg = Release|Any CPU {3EAA45A9-735C-4AC7-A799-947B93EA449D}.Release|Any CPU.Build.0 = Release|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.Build.0 = Release|Any CPU {08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Debug|Any CPU.Build.0 = Debug|Any CPU {08CE9972-283B-44F4-82FA-966F7DFA6B7A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -830,105 +832,116 @@ Global {B5F54272-49F0-40DB-845A-8D837875D3BA}.Release|Win32.ActiveCfg = Release|x86 {B5F54272-49F0-40DB-845A-8D837875D3BA}.Release|x86.Build.0 = Release|x86 {B5F54272-49F0-40DB-845A-8D837875D3BA}.Release|x86.ActiveCfg = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Any CPU.Build.0 = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Any CPU.ActiveCfg = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Win32.Build.0 = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|Win32.ActiveCfg = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|x86.Build.0 = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Debug|x86.ActiveCfg = Debug|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Any CPU.Build.0 = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Any CPU.ActiveCfg = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Win32.Build.0 = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|Win32.ActiveCfg = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|x86.Build.0 = Release|x86 + {80F76D10-0B44-4D55-B4BD-DAEB5464090C}.Release|x86.ActiveCfg = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {B5F54272-49F0-40DB-845A-8D837875D3BA} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} - {DDE2A481-8271-4EAC-A330-8FA6A38D13D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {E73BB233-D88B-44A7-A98F-D71EE158381D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {2FF700C2-A38A-48BD-A637-8CAFD4FE6237} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {C3CBC8E3-81D8-4C5B-9941-DCCD12D50B1F} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {AD6FAA08-D6F5-4DBA-AF85-F4DA9F40C3B5} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {7E4A7172-7FF5-48D0-B719-7CD959DD1AC9} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {80318B5F-A25D-45AB-8A95-EF31D2370A4C} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {2748AD25-9C63-4E12-877B-4DCE96FBED54} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {8035765F-D51F-4A0C-A746-2FD100E19419} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} + {1152B71B-3C05-4598-B20D-823B5D40559E} = {256F5C28-532C-44C0-8AB8-D8EC5E492E01} {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} + {2FF700C2-A38A-48BD-A637-8CAFD4FE6237} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {4139CCF6-FB49-4A9D-B2CF-331E9EA3198D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {E73BB233-D88B-44A7-A98F-D71EE158381D} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} + {DDE2A481-8271-4EAC-A330-8FA6A38D13D1} = {2A232EF1-EB95-41C6-B63A-C106E0C95D3C} {B22522AA-B5BF-4A58-AC6D-D4B45805521F} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} - {F355E45F-F54F-4B42-8916-9A633A392789} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {E0646C25-36F2-4524-969F-FA621353AB94} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} = {E5A0F4D8-37FD-4A30-BEB0-4409DC4E0865} {C4035C32-026F-4158-AF15-113EA1EF1960} = {39327899-ED91-4F7F-988C-4FE4E17C014D} - {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {BDA49550-5ED1-4C6B-B648-657B2CACD8E0} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {C4035C32-026F-4158-AF15-113EA1EF1960} - {E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94} - {7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94} - {BF38FB72-B380-4196-AF8C-95749D726C61} = {E0646C25-36F2-4524-969F-FA621353AB94} - {1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94} - {E1B288A2-08EE-4318-8BBB-8AB72C69E33E} = {E0646C25-36F2-4524-969F-FA621353AB94} - {6E59AF58-F635-459A-9A35-C9AC41C00339} = {E0646C25-36F2-4524-969F-FA621353AB94} - {CA76F702-5B4E-4918-B8D8-7FF8382434FF} = {E0646C25-36F2-4524-969F-FA621353AB94} - {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} = {E0646C25-36F2-4524-969F-FA621353AB94} - {70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94} - {C896FFFF-5B6C-4B0E-B6DF-049865F501B4} = {E0646C25-36F2-4524-969F-FA621353AB94} - {DBCF20A1-BA13-4582-BFA9-74DE4D987B73} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} - {4AC2D5F1-F671-480C-A075-6BF62B3721B2} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} - {8D732610-8FC6-43BA-94C9-7126FD7FE361} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} - {D332F2D1-2CF1-43B7-903C-844BD5211A7E} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} - {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} - {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} - {DEFC8584-BEC3-4921-BD0F-40482E450B7B} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {461606BD-E824-4D0A-8CBA-01810B1F5E02} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {5EEB99CF-EA2B-4733-80A6-CE9192D68170} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {E54A5AD2-418D-4A85-BA5E-CD803DE38715} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {918487B7-2153-4618-BBB3-344DBDDF2A2A} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {4B8F0F98-8BE1-402B-AA8B-C8D548577B38} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {F93E52FD-DA66-4CE5-A0CB-BCD902811122} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {8AA421C8-D7AF-4957-9F43-5135328ACB24} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {3CA90546-3B4C-4663-9445-C4E9371750A7} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} - {0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} - {6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} - {6022AC51-B658-4C54-97EF-79187AC65B47} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {0773ED53-08E2-4495-A3BE-CA0B5D413C15} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {BFA3BF26-33BD-4A65-B84D-C7F30D131668} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {E0646C25-36F2-4524-969F-FA621353AB94} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {F3662720-9EA2-4591-BBC6-97361DCE50A9} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {F355E45F-F54F-4B42-8916-9A633A392789} = {39327899-ED91-4F7F-988C-4FE4E17C014D} + {1F261725-6318-4434-A1B1-6C70CE4CD324} = {F355E45F-F54F-4B42-8916-9A633A392789} + {3EAA45A9-735C-4AC7-A799-947B93EA449D} = {F355E45F-F54F-4B42-8916-9A633A392789} + {08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {F355E45F-F54F-4B42-8916-9A633A392789} + {CE498514-D12D-4B6E-AE0E-FEC29BD43748} = {F355E45F-F54F-4B42-8916-9A633A392789} + {000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} + {E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} + {869951D5-A0D6-4DC6-9F1D-E6B9A12AC446} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} - {A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {EEF5E054-4192-4A57-8FBF-E860D808A51D} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} - {08F772A1-F0BE-433E-8B37-F6522953DB05} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} - {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} - {0991423A-DBF6-4C89-B365-A1DF1EB32E42} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} - {DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} - {DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} - {88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {78CC29AC-CC79-4355-B1F2-97936DF198AC} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {BFA3BF26-33BD-4A65-B84D-C7F30D131668} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {DCA2703D-250A-463E-A68A-07ED105AE6BD} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {0162E499-42D0-409B-AA25-EED21F75336B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {E618A9CD-A39F-4925-A538-E8A3FEF24E54} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {0773ED53-08E2-4495-A3BE-CA0B5D413C15} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} + {6022AC51-B658-4C54-97EF-79187AC65B47} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F} {66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {6022AC51-B658-4C54-97EF-79187AC65B47} - {869951D5-A0D6-4DC6-9F1D-E6B9A12AC446} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} - {E6F4983F-DE41-4AEC-88E7-1FA9AFB4E6FF} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} - {000E4F64-5D0D-4EB1-B0BF-1A62ADBC6EAD} = {D599885D-E161-4CCE-A66E-7A40C8C4F4CC} - {CE498514-D12D-4B6E-AE0E-FEC29BD43748} = {F355E45F-F54F-4B42-8916-9A633A392789} - {08CE9972-283B-44F4-82FA-966F7DFA6B7A} = {F355E45F-F54F-4B42-8916-9A633A392789} - {3EAA45A9-735C-4AC7-A799-947B93EA449D} = {F355E45F-F54F-4B42-8916-9A633A392789} - {1F261725-6318-4434-A1B1-6C70CE4CD324} = {F355E45F-F54F-4B42-8916-9A633A392789} + {9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {78CC29AC-CC79-4355-B1F2-97936DF198AC} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {6022AC51-B658-4C54-97EF-79187AC65B47} + {DC1CCE11-CB91-40FA-9C47-4D9EB5D67BFD} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} + {DFB936AD-90EE-4B4F-941E-4F4A636F0D92} = {0773ED53-08E2-4495-A3BE-CA0B5D413C15} + {0991423A-DBF6-4C89-B365-A1DF1EB32E42} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} + {5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} + {08F772A1-F0BE-433E-8B37-F6522953DB05} = {BFA3BF26-33BD-4A65-B84D-C7F30D131668} + {AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {EEF5E054-4192-4A57-8FBF-E860D808A51D} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {BAD94D6E-4159-4CB6-B991-486F412D9BB6} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {B7823AE9-4B43-4859-8796-2EBDC116FBB8} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {A9F12710-24E4-46D4-832C-6ECB395B9EAD} = {C7F29FC2-1B03-4CDD-9E30-400F4765FF04} + {80F76D10-0B44-4D55-B4BD-DAEB5464090C} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {3CA90546-3B4C-4663-9445-C4E9371750A7} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {9196DD8A-B4D4-4780-8742-C5762E547FC2} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {8AA421C8-D7AF-4957-9F43-5135328ACB24} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {7D5C266F-D6FF-4D14-B315-0C0FC6C4EF51} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {F93E52FD-DA66-4CE5-A0CB-BCD902811122} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {4B8F0F98-8BE1-402B-AA8B-C8D548577B38} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {D022A6CE-7438-41E8-AC64-F2DE18EC54C6} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {5EEB99CF-EA2B-4733-80A6-CE9192D68170} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {64A3E5E6-90BF-47F6-94DF-68C94B62C817} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {461606BD-E824-4D0A-8CBA-01810B1F5E02} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {17F4D7E0-6933-4C2E-8714-FD7E98D625D5} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {DEFC8584-BEC3-4921-BD0F-40482E450B7B} = {F3662720-9EA2-4591-BBC6-97361DCE50A9} + {6B1CFE35-DA17-4DEB-9C6E-227E5E251DA0} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} + {0008FCE9-9EB4-4E2E-979B-553278E5BBA6} = {DEFC8584-BEC3-4921-BD0F-40482E450B7B} + {1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} + {EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {CDE0C5A4-2096-48B5-BEA3-74DBA0F0E1EF} + {C896FFFF-5B6C-4B0E-B6DF-049865F501B4} = {E0646C25-36F2-4524-969F-FA621353AB94} + {70966F84-74C9-4067-A379-0C674A929233} = {E0646C25-36F2-4524-969F-FA621353AB94} + {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} = {E0646C25-36F2-4524-969F-FA621353AB94} + {CA76F702-5B4E-4918-B8D8-7FF8382434FF} = {E0646C25-36F2-4524-969F-FA621353AB94} + {6E59AF58-F635-459A-9A35-C9AC41C00339} = {E0646C25-36F2-4524-969F-FA621353AB94} + {E1B288A2-08EE-4318-8BBB-8AB72C69E33E} = {E0646C25-36F2-4524-969F-FA621353AB94} + {1F1AC7CD-D154-45BB-8EAF-804CA8055F5A} = {E0646C25-36F2-4524-969F-FA621353AB94} + {BF38FB72-B380-4196-AF8C-95749D726C61} = {E0646C25-36F2-4524-969F-FA621353AB94} + {7C96B65D-28A5-4F28-A35B-8D83CE831EE8} = {E0646C25-36F2-4524-969F-FA621353AB94} + {E954F3CB-A446-492F-A664-2B376EBC86E8} = {E0646C25-36F2-4524-969F-FA621353AB94} + {D332F2D1-2CF1-43B7-903C-844BD5211A7E} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} + {8D732610-8FC6-43BA-94C9-7126FD7FE361} = {CA76F702-5B4E-4918-B8D8-7FF8382434FF} + {4AC2D5F1-F671-480C-A075-6BF62B3721B2} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} + {DBCF20A1-BA13-4582-BFA9-74DE4D987B73} = {97B3B514-AB0E-4FE1-89DE-8A945F5112AE} + {D294A12D-4B38-4F25-9AA6-3D4A6CE26E7B} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {BDA49550-5ED1-4C6B-B648-657B2CACD8E0} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {72FFB35A-C9E2-4A31-B4FA-E3E3E28DED5F} = {C4035C32-026F-4158-AF15-113EA1EF1960} + {FE88FE17-D9FB-4FCC-9A35-6BFFB6B26CC6} = {C4035C32-026F-4158-AF15-113EA1EF1960} EndGlobalSection EndGlobal diff --git a/data/layouts/Debug.xml b/data/layouts/Debug.xml index 1ed42b231a..c44fc9cfed 100644 --- a/data/layouts/Debug.xml +++ b/data/layouts/Debug.xml @@ -1,32 +1,56 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/layouts/Default.xml b/data/layouts/Default.xml index 988fb426ab..00ae490078 100644 --- a/data/layouts/Default.xml +++ b/data/layouts/Default.xml @@ -1,22 +1,49 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - + - + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/layouts/Plain.xml b/data/layouts/Plain.xml index da1deb0774..d3bbe459e4 100644 --- a/data/layouts/Plain.xml +++ b/data/layouts/Plain.xml @@ -1,5 +1,43 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/data/resources/StringResources.cz.resx b/data/resources/StringResources.cz.resx index 3fab7c7c7f..5ea3dd799b 100644 --- a/data/resources/StringResources.cz.resx +++ b/data/resources/StringResources.cz.resx @@ -2201,6 +2201,9 @@ Chcete přidat nový soubor do projektu ${CurrentProjectName}? Zobrazit značku EOL + + Zvýrazňovat symboly + Zvýraznit párovou závorku @@ -3015,6 +3018,9 @@ Můžete se také rozhodnout, že všechny volby budou uloženy ve vlastním .us Hodnota resource: + + Stisknutí Ctrl+Mezerník zobrazí položky ze všech jmenných prostorů + Interpreter Boo @@ -5928,6 +5934,9 @@ Soubory resources byly přejmenovány/přesunuty, aby tomu odpovídaly. Prázdný soubor + + Výjimka + Okno pro aplikaci Gtk#. diff --git a/data/resources/StringResources.de.resx b/data/resources/StringResources.de.resx index 868c4804cb..f916814d49 100644 --- a/data/resources/StringResources.de.resx +++ b/data/resources/StringResources.de.resx @@ -232,6 +232,48 @@ Laden Sie ein AddIn aus dem Internet herunter, klicken Sie auf "AddIn installier Klassendiagramm anzeigen + + Inhalt + + + Inhalt anzeigen + + + Suche + + + Hilfebibliothek + + + Hilfetyp + + + Installierte Hilfekataloge + + + Microsoft Help Viewer + + + Suchen + + + Suchen nach: + + + Suche + + + Hilfe anzeigen + + + Externe Hilfe verwenden + + + Ich möchte die lokale Hilfe verwenden + + + Ich möchte die Online-Hilfe verwenden + Anzahl Byte pro Zeile @@ -434,6 +476,9 @@ Installieren Sie das .NET Framework SDK. Alle Funktionen für {0} + + Die gewählte SharpDevelop Profiler-Sitzung wurde mit einer neueren Version von SharpDevelop erstellt und kann daher nicht geöffnet werden. + SharpDevelop Profiling Sitzung @@ -603,6 +648,15 @@ Optional können Sie auch ein Arbeitsverzeichnis und Kommandozeilen-Argumente an Methode extrahieren + + Der ausgewählte Code enthält eine break-Anweisung ohne die übergeordnete Schleife. Bitte ändern Sie die Auswahl! + + + Der ausgewählte Code enthält eine continue-Anweisung ohne die übergeordnete Schleife. Bitte ändern Sie die Auswahl! + + + Der ausgewählte Code enthält eine goto-Anweisung ohne die Sprungmarke. Bitte ändern Sie die Auswahl! + Namen für die neue Methode angeben @@ -615,9 +669,42 @@ Optional können Sie auch ein Arbeitsverzeichnis und Kommandozeilen-Argumente an Extrahieren von Methoden in {0} wird derzeit nicht unterstützt. + + Konstruktor einfügen + + + Auf null prüfen + + + Bereichsprüfung hinzufügen + + + Wählen Sie alle Felder mit denen der Konstruktor erstellt werden soll: + + + Variable + Methode {0} in {1} erstellen + + Equals() und GetHashCode() überschreiben + + + Interface {0} hinzufügen + + + Operatoren überladen + + + Mit #region umschließen + + + ToString() überschreiben + + + Wählen Sie die Felder aus, die Sie in der ToString()-Methode verwenden möchten: + Attribut auflösen: {0} @@ -815,6 +902,15 @@ Sie müssen diese Dateien speichern, bevor die Operation ausgeführt werden kann Muster für Ereignishandler Namen: + + Wählen Sie die Farben, die für die intelligente XAML Syntaxhervorhebung verwendet werden sollen: + + + Hervorhebung + + + Farbe ignorierte Elemente: + Farbe XML Namespace Deklaration: @@ -830,6 +926,15 @@ Sie müssen diese Dateien speichern, bevor die Operation ausgeführt werden kann Vervollständigung von Markup Erweiterungen aktivieren + + Die Datei kann nicht mit der aktuellen Codierung ${encoding} ohne Datenverlust gespeichert werden. + + + Fortsetzen + + + Als UTF-8 speichern + Das Projekt ist als Bibliothek konfiguriert und kein Ausführungskommando wurde angegeben. Ein Ausführungskommando kann in den Projektoptionen eingestellt werden. @@ -1996,6 +2101,12 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen? Beschreibung + + Bitte geben Sie die Liste der Dateierweiterungen mit Strichpunkten getrennt an. (Beispiel: .h;.c;.cpp) + + + &Erweiterungen bearbeiten + &Beschreibung @@ -2359,6 +2470,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen? &Immer Kopie erzeugen + + Standard Dat&eicodierung: + Überwache &Dateien auf externe Änderungen @@ -2500,6 +2614,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen? &Tabs durch Leerzeichen ersetzen + + Strg+Klick für "Gehe zu Definition" verwenden + A&utomatisches Klammereinfügen @@ -2545,6 +2662,9 @@ Wollen Sie die neue Datei zum Projekt ${CurrentProjectName} hinzufügen? Templates &automatisch einfügen + + Intelligente Einrückung verwenden + Code Completion @@ -3390,6 +3510,9 @@ Bitte einen anderen Dateinamen wählen. Text-Editor + + Texteditor (Codierung wählen) + Integrierter Web-Browser @@ -3698,6 +3821,39 @@ Wenn NCover installiert ist, geben sie den Pfad der Anwendung in den ${res:ICSha Ausnahme anzeigen + + Zusätzliche Optionen + + + Zusätzliche Dateien linken + + + Angegebene .NET Module linken + + + Debug-Info generieren + + + Orte für Bibliotheken + + + .NET Ressourcendatei einbetten + + + Präprozessor + + + Definiere folgende Präprozessor-Symbole + + + Orte für Header-Dateien + + + Alle Präprozessor-Symbole entfernen + + + Entferne Definitionen folgender Präprozessor-Symbole + .NET Ressourcendatei (binär) @@ -4445,6 +4601,9 @@ Nur Buchstaben, Ziffern, Leerzeichen, '.' oder '_' sind erlaubt. A&bsteigend + + Externes Werkzeug nicht gefunden + Benutzeranmeldung @@ -4509,6 +4668,9 @@ Grund: Der Wert zu dem zurückgesetzt werden soll ist ungültig weil sich eine a Gibt den Namespace an, in dem das Benutzerdefinierte Tool seine Ausgabe platziert + + Kompletter Pfad zur Datei. + Logischer Name @@ -5357,6 +5519,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Version + + Objektgraph + Bis zum Cursor ausführen @@ -5729,6 +5894,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Die XML-Dokumentationsdatei existiert nicht, Sie müssen das Projekt kompilieren. + + Generieren der Dokumentation aus XML Kommentaren erfordert, dass 'Sandcastle Help File Builder' installiert ist. + Htmle&xport @@ -6078,6 +6246,9 @@ Bitte einen anderen verwenden. Klassen, die von ${Name} erben + + In automatische Eigenschaft konvertieren + Changed-Event erstellen @@ -6096,6 +6267,9 @@ Bitte einen anderen verwenden. deklarierende Klasse + + Automatische Eigenschaft erweitern + Schnittstelle extrahieren @@ -6428,12 +6602,18 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht Letzte Seite + + Weiter + Seiten erzeugt Pdf Datei erzeugen + + Zurück + Zoom @@ -7109,6 +7289,12 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht Konnte .NET Framework-Version für das Programm nicht bestimmen. Stellen Sie sicher, dass das Programm ein e .NET-Anwendung ist. + + Kann nicht an den Prozess anhängen. + + + Der Prozess kann nicht gestartet werden. + Aktion kann nicht durchgeführt werden, da Prozesse gedebugged werden. @@ -7343,6 +7529,9 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht Speichern &unter... + + Mit &Encoding speichern... + F&ormat @@ -7505,6 +7694,9 @@ SharpDevelop 2 kompiliert Ressourcendateien anders: der Ressourcenname ist nicht Erstellt das aktuelle Projekt. + + Erstellt alle Projekte in der aktuellen Solution. + Speichern und aktuelles Projekt oder Datei (wenn kein Projekt geöffnet) erstellen diff --git a/data/resources/StringResources.es-mx.resx b/data/resources/StringResources.es-mx.resx index 82490ec2bc..50910193b8 100644 --- a/data/resources/StringResources.es-mx.resx +++ b/data/resources/StringResources.es-mx.resx @@ -232,6 +232,51 @@ Descargue un complemento de Internet, luego haga clic en "Instalar AddIn" y sele Mostrar Diagrama de Clase + + Contenidos + + + Mostrar Contenidos + + + Búsqueda + + + Biblioteca de Ayuda + + + Modo de Ayuda + + + Catálogos de Ayuda Instalados + + + Visor de Ayuda de Microsoft + + + Usted pidió una característica fuera de línea en la ayuda en línea. Tiene que cambiar el modo para usar esta característica. + + + Buscar + + + Buscar: + + + Búsqueda + + + Mostrar Ayuda + + + Usar ayuda externa + + + Quiero usar ayuda local + + + Quiero usar ayuda en línea + Número de bytes por línea @@ -434,6 +479,9 @@ Necesita instalar el .NET Framework SDK para obtener el sistema de ayuda. Todas las funciones para {0} + + La sesión de análisis de SharpDevelop seleccionada fue creada por una versión más nueva de SharpDevelop y por lo tanto, no puede ser abierta. + Sesión de Análisis de SharpDevelop @@ -603,6 +651,16 @@ Opcionalmente puede especificar un directorio de trabajo y argumentos de línea Extraer método + + El código seleccionado contiene una instrucción break sin el bucle que lo rodea. Por favor, cambié la selección! + + + + El código seleccionado contiene una instrucción continue sin el bucle que lo rodea. Por favor, cambié la selección! + + + El código seleccionado contiene una instrucción goto sin etiqueta. Por favor, cambié la selección! + Ingrese un nombre para el nuevo método @@ -615,9 +673,42 @@ Opcionalmente puede especificar un directorio de trabajo y argumentos de línea La extracción de métodos en {0} no esta soportada actualmente! + + Insertar constructor + + + Agregar verificación de valores null + + + Agregar verificación de rango + + + Seleccione todos los campos con los cuales quiere crear un constructor: + + + Variable + Introducir método {0} en {1} + + Sobrescribir Equals() y GetHashCode() + + + Agregar interface {0} + + + Agregar sobrecargas de operador + + + Rodear con #region + + + Sobrescribir ToString() + + + Seleccione los campos que quiere usar en la implementación de ToString(): + Resolver atributo: {0} @@ -819,6 +910,15 @@ SharpDevelop puede obtener esta información y enviarla automáticamente. Patrón de nombre de controlador de evento: + + Seleccione los colores que deben ser usados por el resaltador XAML: + + + Resaltado + + + Ignorar color de elemento: + Color de declaración de espacio de nombre XML: @@ -834,6 +934,15 @@ SharpDevelop puede obtener esta información y enviarla automáticamente. Usar completado de extensión de marcado + + El archivo no puede ser guardado con la actual codificación ${encoding} sin perder datos. + + + Continuar + + + Guardar como UTF-8 + El proyecto está configurado como una DLL y no se especificó un comando de ejecución. Puede especificar un comando de ejecución en las opciones del proyecto. @@ -2371,6 +2480,9 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Usar archivo &temporal para guardar + + Codificación pr&edeterminada de archivo: + &Detectar cambios externos a archivos @@ -2384,7 +2496,7 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin &Cargar opciones específicas de usuario con el documento - Macintosh + Macintosh (CR) Cargar/Guardar @@ -2393,13 +2505,13 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Guardar - Unix + Unix (LF) Utiliza&r la papelera de reciclaje al eliminar archivos - Windows + Windows (CRLF) Formato @@ -2617,6 +2729,9 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Mostrar marcas de &párrafo + + Resaltar símbolos + Resaltar &corchetes @@ -3405,6 +3520,9 @@ También puede elegir guardar la opción en el archivo .user en lugar de en el a Editor de Texto + + Editor de Texto (elegir codificación) + Explorador Web Integrado @@ -3519,6 +3637,9 @@ También puede elegir guardar la opción en el archivo .user en lugar de en el a Valor de recurso: + + Presione Ctrl+Space para mostrar ítems de todos los espacios de nombre + Interprete Boo @@ -3711,6 +3832,45 @@ También puede elegir guardar la opción en el archivo .user en lugar de en el a Mostrar Excepción + + Opciones adicionales + + + Vinculaciones + + + Vincular archivos adicionales + + + Vincular módulos .NET especificados + + + Generar información de depuración + + + Ubicaciones de bibliotecas de archivos + + + Incrustar archivo de recursos .NET + + + Preprocesador + + + Definir símbolos de preprocesador siguientes + + + Ubicaciones de archivos de cabeceras + + + Quitar definición de todos los símbolos de preprocesador definidos + + + Quitar definición de símbolos de preprocesador siguientes + + + Símbolo + Archivo de recurso .NET (binario) @@ -4235,6 +4395,9 @@ ha sido cambiado de manera externa, ¿desea recargarlo? General + + Generar Controladores de Eventos de Estilos de Visual Studio + Propiedades de cuadricula @@ -5369,6 +5532,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Versión + + Objeto Gráfica + Ejecutar hasta el cursor @@ -6092,6 +6258,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Clases derivadas de ${Name} + + Convertir a propiedad automática + Crear Evento Changed @@ -6110,6 +6279,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Tipo de declaración + + Expandir propiedad automática + Extraer Interfase @@ -6440,12 +6612,18 @@ Los archivos de recursos han sido renombrados/movidos convenientemente. Última Página + + Siguiente + Paginas creadas Crear Archivo Pdf + + Anterior + Zoom @@ -6707,6 +6885,9 @@ Los archivos de recursos han sido renombrados/movidos convenientemente. Archivo Vacío + + Excepción + Una ventana para una aplicación Gtk#. @@ -6830,6 +7011,9 @@ Los archivos de recursos han sido renombrados/movidos convenientemente. Formulario Web ASP.NET + + Manejador Web ASP.NET + Componente de tipo marco para un Servicio Web ASMX. @@ -7361,6 +7545,9 @@ Los archivos de recursos han sido renombrados/movidos convenientemente. Guardar &como... + + Guardar con co&dificación... + F&ormato @@ -7523,6 +7710,9 @@ Los archivos de recursos han sido renombrados/movidos convenientemente. Genera el proyecto actual. + + Genera todos los proyectos en la solución actual. + Genera el proyecto o búfer activo (cuando no existe un proyecto abierto) (guarda automáticamente) diff --git a/data/resources/StringResources.es.resx b/data/resources/StringResources.es.resx index 2075431f30..ac550cfa6e 100644 --- a/data/resources/StringResources.es.resx +++ b/data/resources/StringResources.es.resx @@ -232,6 +232,51 @@ Descargue un complemento de Internet, luego haga clic en 'Instalar Complemento' Mostrar Diagrama de Clase + + Contenidos + + + Mostrar Contenidos + + + Búsqueda + + + Biblioteca de Ayuda + + + Modo de Ayuda + + + Catálogos de Ayuda Instalados + + + Visor de Ayuda de Microsoft + + + Usted a pedido un característica fuera de línea en la ayuda en modo en línea. Debe cambiar el modo para usar esta característica. + + + Buscar + + + Buscar: + + + Búsqueda + + + Mostrar Ayuda + + + Usar ayuda externa + + + Quiero usar ayuda local + + + Quiero usar ayuda en línea + Número de bytes por línea @@ -434,6 +479,9 @@ Es necesario instalar el .NET Framework SDK para obtener el sistema de ayuda. Todas las funciones para {0} + + La sesión de análisis de SharpDevelop seleccionada fue creada por una versión más nueva de SharpDevelop y por lo tanto, no puede ser abierta. + Sesión de Análisis de SharpDevelop @@ -603,6 +651,15 @@ Opcionalmente puede especificar un directorio de trabajo y argumentos de línea Extraer método + + El código seleccionado contiene una instrucción break sin el bucle que lo rodea. Por favor, cambié la selección! + + + El código seleccionado contiene una instrucción continue sin el bucle que lo rodea. Por favor, cambié la selección! + + + El código seleccionado contiene una instrucción goto sin etiqueta. Por favor, cambié la selección! + Ingrese un nombre para el nuevo método @@ -615,9 +672,42 @@ Opcionalmente puede especificar un directorio de trabajo y argumentos de línea La extracción de métodos en {0} no esta soportada actualmente! + + Insertar constructor + + + Agregar verificación de valores null + + + Agregar verificación de rango + + + Seleccione todos los campos con los cuales quiere crear un constructor: + + + Variable + Introducir método {0} en {1} + + Sobrescribir Equals() y GetHashCode() + + + Agregar interface {0} + + + Agregar sobrecargas de operador + + + Rodear con #region + + + Sobrescribir ToString() + + + Seleccione los campos que quiere usar en la implementación de ToString(): + Resolver atributo: {0} @@ -818,6 +908,15 @@ SharpDevelop puede obtener esta información y enviarla automáticamente. Patrón de nombre de controlador de evento: + + Seleccione los colores que deben ser usados por el resaltador XAML: + + + Resaltado + + + Ignorar color de elemento: + Color de declaración de espacio de nombre XML: @@ -833,6 +932,15 @@ SharpDevelop puede obtener esta información y enviarla automáticamente. Usar completado de extensión de marcado + + El archivo no puede ser guardado con la actual codificación ${encoding} sin perder datos. + + + Continuar + + + Guardar como UTF-8 + El proyecto está configurado como una dll y no se especificó un comando ejecutable. Puede especificar un comando ejecutable desde las opciones del proyecto. @@ -2369,6 +2477,9 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Usar archivo &temporal para guardar + + Codificación pr&edeterminada de archivo: + &Detectar cambios externos a archivos @@ -2382,7 +2493,7 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Cargar opciones específicas de usuario con e&l documento - Macintosh + Macintosh (CR) Cargar/Guardar @@ -2391,13 +2502,13 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Guardar - Unix + Unix (LF) Utiliza&r la papelera de reciclaje al eliminar archivos - Windows + Windows (CRLF) Formato @@ -2615,6 +2726,9 @@ Adicionalmente, se le puede asignar a una extensión un conjunto de reglas defin Mostrar marcas de &párrafo + + Resaltar símbolos + Resaltar &corchetes @@ -3407,6 +3521,9 @@ También puede escoger almacenar el parámetro de configuración en el archivo . Editor de Texto + + Editor de Texto (elegir codificación) + Explorador Web Integrado @@ -3521,6 +3638,9 @@ También puede escoger almacenar el parámetro de configuración en el archivo . Valor de recurso: + + Presione Ctrl+Space para mostrar ítems de todos los espacios de nombre + Interprete Boo @@ -3713,6 +3833,45 @@ También puede escoger almacenar el parámetro de configuración en el archivo . Mostrar Excepción + + Opciones adicionales + + + Vinculaciones + + + Vincular archivos adicionales + + + Vincular módulos .NET especificados + + + Generar información de depuración + + + Ubicaciones de bibliotecas de archivos + + + Incrustar archivo de recursos .NET + + + Preprocesador + + + Definir símbolos de preprocesador siguientes + + + Ubicaciones de archivos de cabezeras + + + Quitar definición de todos los símbolos de preprocesador definidos + + + Quitar definición de símbolos de preprocesador siguientes + + + Símbolo + Archivo de Recurso de .NET (binario) @@ -4238,6 +4397,9 @@ ha sido modificado externamente, ¿desea volver a cargarlo? General + + Generar Controladores de Eventos de Estilos de Visual Studio + Propiedades de la rejilla @@ -5373,6 +5535,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Versión + + Objeto Gráfica + Ejecutar hasta el cursor @@ -6096,6 +6261,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Clases derivadas de ${Name} + + Convertir a propiedad automática + Crear un evento Changed @@ -6114,6 +6282,9 @@ Microsoft.Tools.WindowsInstallerXml.Extensions.NetFxCompiler, WixNetFxExtension< Tipo de declaración + + Expandir propiedad automática + Extraer Interfase @@ -6445,12 +6616,18 @@ Los archivos de recursos han sido renombrados o cambiados de ubicación de acuer Última Página + + Siguiente + Paginas creadas Crer Archivo Pdf + + Anterior + Zoom @@ -6712,6 +6889,9 @@ Los archivos de recursos han sido renombrados o cambiados de ubicación de acuer Archivo en Blanco + + Excepción + Crea una ventana para una aplicación Gtk#. @@ -6835,6 +7015,9 @@ Los archivos de recursos han sido renombrados o cambiados de ubicación de acuer Formulario Web ASP.NET + + Manejador Web ASP.NET + Componente de tipo marco para un Servicio Web ASMX. @@ -7366,6 +7549,9 @@ Los archivos de recursos han sido renombrados o cambiados de ubicación de acuer Guardar &como... + + Guardar con co&dificación... + F&ormato @@ -7528,6 +7714,9 @@ Los archivos de recursos han sido renombrados o cambiados de ubicación de acuer Genera el proyecto abierto. + + Genera todos los proyectos en la solución actual. + Generar proyecto o búfer activo (en caso de estar abierto un proyecto, lo guarda automáticamente) diff --git a/data/resources/StringResources.fr.resx b/data/resources/StringResources.fr.resx index cbda66acbb..db441a5c1c 100644 --- a/data/resources/StringResources.fr.resx +++ b/data/resources/StringResources.fr.resx @@ -127,7 +127,7 @@ Annuler l'installation - Annuler la mise a jour + Annuler la mise à jour Désactiver @@ -142,7 +142,7 @@ Désinstaller - Mettre a jour + Mettre à jour Une dépendance de cet AddIn n'a pas été trouvée. Installez la pour activer cet AddIn. @@ -232,6 +232,51 @@ Téléchargez un AddIn depuis l'Internet, cliquez ensuite sur 'Installer un AddI Afficher le diagramme des classes + + Contenus + + + Afficher Contenus + + + Rechercher + + + Bibliothèque d'Aide + + + Mode d'Aide + + + Installer les Catalogues d'Aide + + + Visionneuse de l'aide Microsoft + + + Vous avez demandé une fonctionnalité su mode hors-ligne depuis le mode en-ligne. Changez de mode pour utiliser cette fonctionnalité. + + + Rechercher + + + Chercher: + + + Rechercher + + + Afficher l'Aide + + + Utiliser l'aide externe + + + Je souhaite utiliser l'aide locale + + + Je souhaite utiliser l'aide en ligne + Nombre d'octets par ligne @@ -885,6 +930,15 @@ Sauvegardez ces fichiers avant de déclencher l'opération. Utiliser la complétion d'extension + + Impossible de sauvegarder sans perte d'informations avec l'encodage ${encoding} + + + Continuer + + + Sauvegarder en UTF-8 + Le projet est configuré comme dll et aucune commande a exécuter n'a été spécifiée. Vous pouvez spécifier une commande a exécuter dans les options du projet. @@ -1978,7 +2032,7 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Le répertoire '{0}' n'existe pas. - Choisir le répertoire où chercher + Choisir le répertoire de recherche Projet entier @@ -2011,7 +2065,7 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Rechercher dans: - Expression régulière + Expressions rationnelles Recherche standard @@ -2248,7 +2302,7 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Autres options - Assistant Assemblage + Explorateur d'Assemblies Membres privés : @@ -2418,6 +2472,9 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Utiliser un fichier &temporaire pour la sauvegarde + + &Encodage par défaut: + &Détecter les changements externes des fichiers @@ -2431,7 +2488,7 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Charger &les préférences utilisateur avec le document - Macintosh + Apple (CR) Charger/Sauver @@ -2440,13 +2497,13 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Enregistrer - Unix + Unix (LF) Utiliser la corbeille lors de l'effacement des fichiers - Windows + Windows (CRLF) Format @@ -2664,6 +2721,9 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Affich&er les marqueurs de fin de ligne + + Surligner symboles + Accolades en surbrillance @@ -2734,7 +2794,7 @@ Voulez-vous ajouter le nouveau fichier au projet ${CurrentProjectName}? Application Windows - Sélectionner le répertoire d'assemblage + Sélectionner le répertoire de création de l'assembly. Intégré : @@ -3455,6 +3515,9 @@ Vous pouvez aussi choisir de stocker la configuration dans le fichier .user-file Editeur de texte + + Editeur de texte (choisir l'encodage) + Navigateur embarqué @@ -3569,6 +3632,9 @@ Vous pouvez aussi choisir de stocker la configuration dans le fichier .user-file Valeur de la ressource: + + Ctrl+Espace affiche les éléments pour tous les espaces de noms + Interpréteur Boo @@ -4233,7 +4299,7 @@ Toutes les modifications seront perdues. Erreur au chargement du concepteur: - Assemblage + Assembly Emplacement @@ -4272,7 +4338,7 @@ Toutes les modifications seront perdues. &Ajouter des composants - Assemblage + Assembly Catégories @@ -4325,6 +4391,9 @@ Toutes les modifications seront perdues. Général + + Générer des gestionnaires d'évènement à la Visual Studio + Propriétés de la grille @@ -5964,7 +6033,7 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace Visibilité publique - Expressions rationelles + Expression rationnelle Remplacer @@ -6018,7 +6087,7 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace correspondances - Veuillez entrer une expression régulière + Veuillez entrer une expression rationnelle Caractère numérique @@ -6075,7 +6144,7 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace Copier le nom de la ressource - &Renomer + &Renommer Visualiser en Hexadécimal @@ -6090,7 +6159,7 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace Tous les fichiers (*.*) - Fichiers d'assemblages (*.exe;*.dll) + Fichiers d'Assemblies (*.exe;*.dll) Fichiers binaires @@ -6279,7 +6348,7 @@ Soit ils n'existent pas, soit le document Wix n'est pas pour WiX 3.0 et l'espace &Renommer - SharpDevelop doit-il renomer la propriété '{0}' en '{1}'? + SharpDevelop doit-il renommer la propriété '{0}' en '{1}'? Renommer le fichier en '${FileName}' @@ -6539,12 +6608,18 @@ Les fichiers de resources ont été renommés/déplacés en conséquence. Dernière page + + Suivant + Pages créées Créer un fichier PDF + + Précédent + Zoomer @@ -6806,6 +6881,9 @@ Les fichiers de resources ont été renommés/déplacés en conséquence. Fichier vide + + Exception + Une fenêtre pour application GTK#. @@ -6929,6 +7007,9 @@ Les fichiers de resources ont été renommés/déplacés en conséquence. Formulaire Web ASP.NET + + Gestionnaire ASP.NET + Brique de composant pour service Web ASMX @@ -7460,6 +7541,9 @@ Les fichiers de resources ont été renommés/déplacés en conséquence. Enregistrer &sous + + Sauvegarder avec l'&encodage... + F&ormat @@ -7723,7 +7807,7 @@ Erreur lors du démarrage: Documentation XML rapide - Expressions régulières + Boîte à outils Expressions Rationnelles &Affichage diff --git a/data/resources/StringResources.nl.resx b/data/resources/StringResources.nl.resx index ef44fd4389..0c03f24dd7 100644 --- a/data/resources/StringResources.nl.resx +++ b/data/resources/StringResources.nl.resx @@ -231,6 +231,51 @@ Klassendiagram weergeven + + Inhoud + + + Inhoud weergeven + + + Zoeken + + + Help Bibliotheek + + + Help modus + + + Geïnstalleerde Help Catalogi + + + Microsoft Help Viewer + + + U vroeg om een offline kenmerk in de online help-modus. U dient de modus te wijzigen om dit kenmerk te kunnen gebruiken. + + + Zoek nu + + + Zoeken naar: + + + Zoeken + + + Help tonen + + + Externe help gebruiken + + + Ik kies voor gebruik van plaatselijke help + + + Ik kies voor gebruik van online help + Aantal bytes per regel @@ -885,6 +930,15 @@ De geselecteerde code bevat een break commando zonder de insluitende lus. Wijzig Gebruik markup extentie completeren + + Het bestand kan niet zonder gegevens verlies met de momentele encodering ${encoding} worden opgeslagen. + + + Voortzetten + + + Opslaan als UTF-8 + Het project is geconfigureerd als een DLL en er is geen uitvoeringscommando ingesteld. Je kan een uitvoeringscommando in de project opties instellen. @@ -2425,6 +2479,9 @@ Wilt u het nieuwe bestand toevoegen aan project ${CurrentProjectName}? Gebruik &tijdelijk bestand voor opslaan + + Verstek bestands &encodering: + Externe bestandswijzigingen &detecteren @@ -2671,6 +2728,9 @@ Wilt u het nieuwe bestand toevoegen aan project ${CurrentProjectName}? &EOL markeringen weergeven + + Markeer symbolen + &Markeren passend haakje @@ -3458,6 +3518,9 @@ Er kan worden gekozen voor opslag van de instellingen in het .user bestand inpla Tekst bewerker + + Tekstbewerker (kies encodering) + Ingebouwde Web browser @@ -3572,6 +3635,9 @@ Er kan worden gekozen voor opslag van de instellingen in het .user bestand inpla Hulpbron waarde: + + Drk Ctrl+spatie in om items van alle naamruimten weer te geven, + Boo interpreteren @@ -4327,6 +4393,9 @@ Noot: Dit beïnvloed eigen aangepaste opmaak niet. Algemeen + + Genereer Visual Studio stijl event handlers + Raster eigenschappen @@ -6540,12 +6609,18 @@ De hulpbron bestanden zijn hernoemd/verplaatst op de beschreven wijze. Laatste pagina + + Verder + Pagina's aangemaakt Maak Pdf bestand + + Terug + Zoom @@ -6808,6 +6883,9 @@ De hulpbron bestanden zijn hernoemd/verplaatst op de beschreven wijze. Leeg bestand + + Uitzondering + Venster voor een Gtk# toepassing. @@ -6931,6 +7009,9 @@ De hulpbron bestanden zijn hernoemd/verplaatst op de beschreven wijze. ASP.NET Web Formulier + + ASP.NET behandelaar + Component Frame voor ASMX Web Service. @@ -7462,6 +7543,9 @@ De hulpbron bestanden zijn hernoemd/verplaatst op de beschreven wijze. Opslaan als... + + Opslaan met &encoding... + &Indeling diff --git a/data/resources/StringResources.pt-br.resx b/data/resources/StringResources.pt-br.resx index 311748f7e9..a3a6ec6042 100644 --- a/data/resources/StringResources.pt-br.resx +++ b/data/resources/StringResources.pt-br.resx @@ -228,6 +228,60 @@ Formato de arquivo desconhecido. + + Mostrar Diagrama de Classes + + + Conteudo + + + Mostra Conteudo + + + Biblioteca de ajuda + + + Modo Ajuda + + + Catalogos de Ajuda instalados + + + Visualizador de Ajuda da Microsoft + + + Você solicitou um recurso desconectado, no modo de ajuda conectado. Você tem que mudar o modo para utilizar esta funcionalidade. + + + Mostra Ajuda + + + Usa ajuda externa + + + Eu desejo usar ajuda local + + + Eu quero usar ajuda online + + + Numbero de bytes por linha + + + Visualizar + + + Elementos + + + Dado + + + Compensar + + + Sistema de numeração + Redimensionar para ajustar a largura atual. @@ -403,12 +457,222 @@ Voce precisa instalar o .Net Framework SDK para acessar o sistema de ajuda. Use o idioma corrente para o Projeto + + Resultado + + + Nós fundidos + + + Todas as funções para {0} + + + A sessão do perfil do SharpDevelop selecionada foi criado por uma versão mais recente do SharpDevelop e, portanto, não pode ser aberta. + + + Perfil da sessão do SharpDevelop + + + Este projeto não pode ser iniciado porque o arquivo executável não foi encontrado, certifique-se de que o projeto e todas as suas dependencias estão construídos corretamente! + + + Nenhum projeto inicializavel foi encontrado. Abortando... + + + Este projeto não pode ser iniciado. Deseja configurar, na Solução, o projeto a ser iniciado? + + + Preparando para analises... + + + Não foi possível registrar o Profiler no Registro COM. Não é possível iniciar perfil + + + Não foi possível cancelar o profiler do registro COM! + + + Perfil + + + Combinar chamadas recursivas. + + + Não crie perfil para chamadas .Net internas. + + + Coletar dados apenas ao final da sessão. + + + Iniciar a coleta de dados imediatamente após o inicio da sessão. + + + Coleção de Dados + + + Tamanho do arquivo temporario de armazenamento: + + + Geral + + + Perfil + + + Perfil do projeto atual + + + Selecionar executavel para o perfil + + + Dado invalido. Por favor, tente novamente! + + + Argumentos da linha de comando: + + + Selecionar o caminho do executavel que voce quer para o perfil. Opcionalmente, voce pode especificar o diretorio de trabalho e os argumentos da linha de comando. + + + Caminho do executavel: + + + Iniciar o perfil + + + Perfil do executavel + + + Diretorio de trabalho: + + + Coletar dados + + + Terminar + + + Janela de controle do perfil + + + Contagem de chamadas + + + Chamadas: + + + Limpa historico de consulta + + + Copia dado selecionado + + + Copiar rastreamento de pilha + + + Achar chamadas das funções selecionadas + + + Ir para definição + + + Definir como raiz/Unir + + + Mostrar funções + + + Ciclos de CPU: + + + Executar consulta + + + Expandir caminho escolhido + + + Nome + + + Visão global + + + Historico de Consulta + + + Pesquisar: + + + Mostrar barra de consulta + + + % do pai + + + Tempo gasto + + + Tempo gasto/chamada + + + Tempo gasto (proprio) + + + Tempo gasto (proprio)/chamada + + + Tempo: + + + Analisador de Perfis de Sessão + + + Os 20 mais + + + Atualizando a tela, aguarde... + + + Executar com perfil + Extrair método. + + O código selecionado contém uma declaração de parar sem fechar o ciclo. Por favor, altere a seleção! + + + O código selecionado contém uma declaração de continuar sem fechar o ciclo. Por favor, altere a seleção! + + + O código selecionado contém uma instrução de ir para mas sem rótulo. Por favor, altere a seleção! + + + Entrar com o nome para o novo metodo + + + Seleção invalida! Favor selecionar uma faixa valida. + + + Ocorreram erros durante a análise! Não é possível extrair um novo método. + Atualmente não é suportado extrair métodos em {0}! + + Inserir construtor + + + Adicionar validação para nulo + + + Adicionar validação para faixa + + + Selecionar todos os campos que voce deseja criar com o construtor: + + + Variavel + Adicionar a lista ignore. @@ -442,6 +706,9 @@ Voce precisa instalar o .Net Framework SDK para acessar o sistema de ajuda. Historico + + Obter trava + Marcar conflitos como resolvidos @@ -1660,6 +1927,12 @@ Além disso, um span pode definir um rule set nomedo que permite uma formataçã Descrição + + Por favor, entre com a lista de extensões de arquivos separadas por ponto-evírgula. (Exemplo:. H;. C;. Cpp + + + &Editar extensões + &Descrição @@ -4019,18 +4292,39 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Substituído com Sucesso. + + Todos os testes + Cobertura de Código + + Executar todos os testes com cobertura de código + Executa na mesa de teste unitário + + Executar os testes no projeto corrente. + Executar com cobertura de código Executar com depurador + + Arquivos com extensão WiX + + + Suprimir ICEs: + + + Caminho para arquivos WiX: + + + Caminho para tarefas WiX: + Biblioteca @@ -4040,12 +4334,18 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Arquivos de Instalação + + Adicionar extensão WiX + Diálogos de Instalação Nenhum diálogo de instalação selecionado no documento Wix. Por favor mova o cursor dentro de um elemento de diálogo ou use as janelas de Diálogos de Instalação para abrir um diálogo. + + Extensões WiX + &Assinala XSLT... @@ -4253,6 +4553,9 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Voce não pode mudar para uma função sem simbolos. + + [Métodos externos] + Mudar função @@ -4268,6 +4571,9 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Mostrar métodos externos + + Na {0} em {1}: linha {2} + Excessão {0} foi disparada no depurador: @@ -5456,6 +5762,12 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Aplicações Windows + + Classes que herdam ConfigurationElementCollection. + + + Coleção de Elementos de Configuração + Declaração de uma classe vazia. @@ -5807,6 +6119,9 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. &Depurar + + Anexar ao processo... + &Breque @@ -5819,6 +6134,18 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Continuar a execução do processo. + + Não é possível obter a versão do .NET Framework do programa. Verifique se o programa é um assembly gerenciado. + + + Não pode anexar ao processo. + + + Não pode iniciar o processo. + + + Não é suportado depurar programas do .Net Framework 1.0. + Executar &sem depuração @@ -5918,6 +6245,12 @@ Use somente letras, dígitos, espaço, "." ou "_" são permitidos. Co&lar + + Colar como comentário + + + Colar como string + Colar texto da Área de Transferência diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 84730ab371..ebbafad3f1 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -232,6 +232,51 @@ Download an AddIn from the Internet, then click 'Install AddIn' and choose the d Show Class Diagram + + Contents + + + Display Contents + + + Search + + + Help Library + + + Help Mode + + + Installed Help Catalogs + + + Microsoft Help Viewer + + + You requested an offline feature in the online help mode. You have to change the mode in order to use this feature. + + + Search + + + Look for: + + + Search + + + Show Help + + + Use external help + + + I want to use local help + + + I want to use online help + Number of bytes per line @@ -2437,6 +2482,9 @@ Do you want to add the new file to the project ${CurrentProjectName}? Use &temporary file for saving + + Default file &encoding: + &Detect external changes to files @@ -2450,7 +2498,7 @@ Do you want to add the new file to the project ${CurrentProjectName}? &Load user-specific settings with the document - Macintosh + Macintosh (CR) Load/Save @@ -2459,13 +2507,13 @@ Do you want to add the new file to the project ${CurrentProjectName}? Save - Unix + Unix (LF) Use &recycle bin when deleting files - Windows + Windows (CRLF) Format @@ -2683,6 +2731,9 @@ Do you want to add the new file to the project ${CurrentProjectName}? Show &end-of-line markers + + Highlight symbols + Highlight &matching bracket @@ -3590,6 +3641,9 @@ You can also choose to store the setting in the .user-file instead of the projec Resource value: + + Press Ctrl+Space to show items from all namespaces + Boo Interpreter @@ -4352,6 +4406,9 @@ has been changed externally do you want to reload it? General + + Generate Visual Studio Style Event Handlers + Grid Properties @@ -6567,12 +6624,18 @@ The resources files have been renamed/moved accordingly. Last Page + + Next + Pages created Create PdfFile + + Previous + Zoom @@ -6834,6 +6897,9 @@ The resources files have been renamed/moved accordingly. Empty File + + Exception + A window for a Gtk# application. @@ -6957,6 +7023,9 @@ The resources files have been renamed/moved accordingly. ASP.NET Web Form + + ASP.NET Web Handler + Component Frame for ASMX Web Service. diff --git a/data/templates/file/CSharp/CSharp.Exception.xft b/data/templates/file/CSharp/CSharp.Exception.xft new file mode 100644 index 0000000000..bb60841b79 --- /dev/null +++ b/data/templates/file/CSharp/CSharp.Exception.xft @@ -0,0 +1,66 @@ + + diff --git a/samples/AvalonEdit.Sample/MyCompletionData.cs b/samples/AvalonEdit.Sample/MyCompletionData.cs index 8295e25c33..7ab77048a3 100644 --- a/samples/AvalonEdit.Sample/MyCompletionData.cs +++ b/samples/AvalonEdit.Sample/MyCompletionData.cs @@ -48,6 +48,8 @@ namespace AvalonEdit.Sample get { return "Description for " + this.Text; } } + public double Priority { get { return 0; } } + public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs) { textArea.Document.Replace(completionSegment, this.Text); diff --git a/samples/Gallio/Gallio.Extension/Gallio.Extension.csproj b/samples/Gallio/Gallio.Extension/Gallio.Extension.csproj new file mode 100644 index 0000000000..7b379e1670 --- /dev/null +++ b/samples/Gallio/Gallio.Extension/Gallio.Extension.csproj @@ -0,0 +1,60 @@ + + + + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F} + Debug + x86 + Library + Gallio.Extension + Gallio.Extension + v3.5 + Properties + False + False + 4 + false + + + x86 + False + Auto + 4194304 + 4096 + + + bin\Debug\ + true + Full + False + True + DEBUG;TRACE + + + bin\Release\ + False + None + True + False + TRACE + + + + ..\Gallio\bin\Gallio.dll + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Gallio/Gallio.Extension/GallioTestStepConverter.cs b/samples/Gallio/Gallio.Extension/GallioTestStepConverter.cs new file mode 100644 index 0000000000..f15fec7329 --- /dev/null +++ b/samples/Gallio/Gallio.Extension/GallioTestStepConverter.cs @@ -0,0 +1,78 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using Model = Gallio.Model; +using Gallio.Common.Markup; +using Gallio.Runner.Events; + +namespace Gallio.Extension +{ + public class GallioTestStepConverter + { + TestStepEventArgs eventArgs; + TestResult testResult; + SharpDevelopTagFormatter tagFormatter; + + public GallioTestStepConverter(TestStepEventArgs eventArgs) + { + this.eventArgs = eventArgs; + Convert(); + } + + void Convert() + { + CreateTestResult(); + ConvertTestOutcome(); + ConvertTestMessages(); + } + + void CreateTestResult() + { + string name = GetTestName(); + testResult = new TestResult(name); + } + + string GetTestName() + { + return eventArgs.Test.FullName.Replace('/', '.'); + } + + void ConvertTestOutcome() + { + testResult.ResultType = GetTestResultType(eventArgs.TestStepRun.Result.Outcome.Status); + } + + TestResultType GetTestResultType(Model.TestStatus status) + { + switch (status) { + case Model.TestStatus.Passed: + return TestResultType.Success; + case Model.TestStatus.Skipped: + case Model.TestStatus.Inconclusive: + return TestResultType.Ignored; + case Model.TestStatus.Failed: + return TestResultType.Failure; + } + return TestResultType.None; + } + + void ConvertTestMessages() + { + tagFormatter = new SharpDevelopTagFormatter(); + tagFormatter.Visit(eventArgs.TestStepRun); + testResult.Message = tagFormatter.TestResultMessage; + testResult.StackTrace = tagFormatter.GetStackTrace(); + } + + public TestResult GetTestResult() + { + return testResult; + } + } +} diff --git a/samples/Gallio/Gallio.Extension/ITestResultsWriter.cs b/samples/Gallio/Gallio.Extension/ITestResultsWriter.cs new file mode 100644 index 0000000000..1ed6c328ba --- /dev/null +++ b/samples/Gallio/Gallio.Extension/ITestResultsWriter.cs @@ -0,0 +1,16 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Gallio.Extension +{ + public interface ITestResultsWriter : IDisposable + { + void Write(TestResult testResult); + } +} diff --git a/samples/Gallio/Gallio.Extension/ITestResultsWriterFactory.cs b/samples/Gallio/Gallio.Extension/ITestResultsWriterFactory.cs new file mode 100644 index 0000000000..b72bbee632 --- /dev/null +++ b/samples/Gallio/Gallio.Extension/ITestResultsWriterFactory.cs @@ -0,0 +1,16 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Gallio.Extension +{ + public interface ITestResultsWriterFactory + { + ITestResultsWriter Create(string fileName); + } +} diff --git a/samples/Gallio/Gallio.Extension/MultiLineTestResultText.cs b/samples/Gallio/Gallio.Extension/MultiLineTestResultText.cs new file mode 100644 index 0000000000..aec199e35b --- /dev/null +++ b/samples/Gallio/Gallio.Extension/MultiLineTestResultText.cs @@ -0,0 +1,54 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text; + +namespace Gallio.Extension +{ + public class MultiLineTestResultText + { + StringBuilder textBuilder = new StringBuilder(); + + public MultiLineTestResultText(string text) + { + EncodeText(text); + } + + public override string ToString() + { + return textBuilder.ToString(); + } + + /// + /// Replaces the first character on each new line with a space. + /// The first line does not have the extra space added. + /// + void EncodeText(string text) + { + if (String.IsNullOrEmpty(text)) { + return; + } + + text = text.TrimEnd(Environment.NewLine.ToCharArray()); + + foreach (char ch in text) { + switch (ch) { + case '\n': + textBuilder.Append("\r\n "); + break; + case '\r': + // Ignore. + break; + default: + textBuilder.Append(ch); + break; + } + } + } + } +} diff --git a/samples/Gallio/Gallio.Extension/Properties/AssemblyInfo.cs b/samples/Gallio/Gallio.Extension/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..d35a1df3c7 --- /dev/null +++ b/samples/Gallio/Gallio.Extension/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Gallio.Extension")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Gallio.Extension")] +[assembly: AssemblyCopyright("Copyright 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.*")] diff --git a/samples/Gallio/Gallio.Extension/SharpDevelopTagFormatter.cs b/samples/Gallio/Gallio.Extension/SharpDevelopTagFormatter.cs new file mode 100644 index 0000000000..edc68a3bd8 --- /dev/null +++ b/samples/Gallio/Gallio.Extension/SharpDevelopTagFormatter.cs @@ -0,0 +1,68 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text; +using Gallio.Common.Markup; +using Gallio.Common.Markup.Tags; +using Gallio.Runner.Reports.Schema; + +namespace Gallio.Extension +{ + public class SharpDevelopTagFormatter : ITagVisitor + { + StringBuilder textBuilder = new StringBuilder(); + string testResultMessage = String.Empty; + + public void Visit(TestStepRun testStepRun) + { + foreach (StructuredStream stream in testStepRun.TestLog.Streams) { + VisitBodyTag(stream.Body); + } + } + + public void VisitBodyTag(BodyTag tag) + { + foreach (Tag childTag in tag.Contents) { + childTag.Accept(this); + } + } + + public void VisitSectionTag(SectionTag tag) + { + textBuilder.Append(tag.Name + " "); + tag.AcceptContents(this); + } + + public void VisitMarkerTag(MarkerTag tag) + { + if (tag.Class == Marker.StackTraceClass) { + testResultMessage = textBuilder.ToString(); + textBuilder = new StringBuilder(); + } + tag.AcceptContents(this); + } + + public void VisitEmbedTag(EmbedTag tag) + { + } + + public void VisitTextTag(TextTag tag) + { + textBuilder.Append(tag.Text); + } + + public string TestResultMessage { + get { return testResultMessage; } + } + + public string GetStackTrace() + { + return textBuilder.ToString(); + } + } +} diff --git a/samples/Gallio/Gallio.Extension/SharpDevelopTestRunnerExtension.cs b/samples/Gallio/Gallio.Extension/SharpDevelopTestRunnerExtension.cs new file mode 100644 index 0000000000..48ee05e4fd --- /dev/null +++ b/samples/Gallio/Gallio.Extension/SharpDevelopTestRunnerExtension.cs @@ -0,0 +1,51 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using Gallio.Runner.Events; +using Gallio.Runner.Extensions; + +namespace Gallio.Extension +{ + public class SharpDevelopTestRunnerExtension : TestRunnerExtension + { + ITestResultsWriterFactory factory; + ITestResultsWriter writer; + + public SharpDevelopTestRunnerExtension(ITestResultsWriterFactory factory) + { + this.factory = factory; + } + + public SharpDevelopTestRunnerExtension() + : this(new TestResultsWriterFactory()) + { + } + + protected override void Initialize() + { + writer = factory.Create(Parameters); + Events.TestStepFinished += TestStepFinished; + Events.DisposeStarted += DisposeStarted; + } + + void TestStepFinished(object source, TestStepFinishedEventArgs e) + { + if (e.Test.IsTestCase) { + GallioTestStepConverter testStep = new GallioTestStepConverter(e); + TestResult testResult = testStep.GetTestResult(); + writer.Write(testResult); + } + } + + void DisposeStarted(object source, DisposeStartedEventArgs e) + { + writer.Dispose(); + } + } +} \ No newline at end of file diff --git a/samples/Gallio/Gallio.Extension/TestResult.cs b/samples/Gallio/Gallio.Extension/TestResult.cs new file mode 100644 index 0000000000..fce1e5f28b --- /dev/null +++ b/samples/Gallio/Gallio.Extension/TestResult.cs @@ -0,0 +1,80 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Gallio.Extension +{ + public enum TestResultType { + /// + /// The test has not been run. + /// + None = 0, + + /// + /// The test passed. + /// + Success = 1, + + /// + /// The test failed. + /// + Failure = 2, + + /// + /// The test was ignored. + /// + Ignored = 3 + } + + /// + /// Holds the information about a single test result. + /// + public class TestResult + { + string name = String.Empty; + string message = String.Empty; + string stackTrace = String.Empty; + TestResultType resultType = TestResultType.None; + + public TestResult(string name) + { + this.name = name; + } + + public string Name { + get { return name; } + } + + public bool IsSuccess { + get { return resultType == TestResultType.Success; } + } + + public bool IsFailure { + get { return resultType == TestResultType.Failure; } + } + + public bool IsIgnored { + get { return resultType == TestResultType.Ignored; } + } + + public TestResultType ResultType { + get { return resultType; } + set { resultType = value; } + } + + public string Message { + get { return message; } + set { message = value; } + } + + public string StackTrace { + get { return stackTrace; } + set { stackTrace = value; } + } + } +} diff --git a/samples/Gallio/Gallio.Extension/TestResultsWriter.cs b/samples/Gallio/Gallio.Extension/TestResultsWriter.cs new file mode 100644 index 0000000000..735d497479 --- /dev/null +++ b/samples/Gallio/Gallio.Extension/TestResultsWriter.cs @@ -0,0 +1,90 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; + +namespace Gallio.Extension +{ + public class TestResultsWriter : ITestResultsWriter, IDisposable + { + TextWriter writer; + + public TestResultsWriter(string fileName) + : this(new StreamWriter(fileName, false, Encoding.UTF8)) + { + } + + public TestResultsWriter(TextWriter writer) + { + this.writer = writer; + } + + public void Write(TestResult testResult) + { + WriteTestName(testResult.Name); + WriteResult(testResult.ResultType); + + if (testResult.ResultType == TestResultType.Failure) { + WriteTestFailureResult(testResult); + } + } + + void WriteTestName(string name) + { + WriteNameAndValue("Name", name); + } + + void WriteResult(TestResultType resultType) + { + string result = GetResult(resultType); + WriteNameAndValue("Result", result); + } + + void WriteTestFailureResult(TestResult testResult) + { + WriteNameAndMultiLineValue("Message", testResult.Message); + WriteNameAndMultiLineValue("StackTrace", testResult.StackTrace); + } + + void WriteNameAndValue(string name, string value) + { + string nameAndValue = String.Format("{0}: {1}", name, value); + WriteLine(nameAndValue); + } + + string GetResult(TestResultType resultType) + { + switch (resultType) { + case TestResultType.Success: + return "Success"; + case TestResultType.Ignored: + return "Ignored"; + case TestResultType.Failure: + return "Failure"; + } + return String.Empty; + } + + void WriteNameAndMultiLineValue(string name, string value) + { + MultiLineTestResultText multiLineText = new MultiLineTestResultText(value); + WriteNameAndValue(name, multiLineText.ToString()); + } + + void WriteLine(string text) + { + writer.WriteLine(text); + } + + public void Dispose() + { + writer.Dispose(); + } + } +} diff --git a/samples/Gallio/Gallio.Extension/TestResultsWriterFactory.cs b/samples/Gallio/Gallio.Extension/TestResultsWriterFactory.cs new file mode 100644 index 0000000000..3c16b25ffb --- /dev/null +++ b/samples/Gallio/Gallio.Extension/TestResultsWriterFactory.cs @@ -0,0 +1,19 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Gallio.Extension +{ + public class TestResultsWriterFactory : ITestResultsWriterFactory + { + public ITestResultsWriter Create(string fileName) + { + return new TestResultsWriter(fileName); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Gallio.SharpDevelop.Tests.csproj b/samples/Gallio/Gallio.SharpDevelop.Tests/Gallio.SharpDevelop.Tests.csproj new file mode 100644 index 0000000000..3feaf83c68 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Gallio.SharpDevelop.Tests.csproj @@ -0,0 +1,99 @@ + + + + {3F6C539D-DB38-41B4-A5B3-B9A52AE607CD} + Debug + x86 + Library + Gallio.SharpDevelop.Tests + Gallio.SharpDevelop.Tests + v4.0 + C:\Users\Matt\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis + False + False + 4 + false + + + x86 + False + Auto + 4194304 + 4096 + + + bin\Debug\ + true + Full + False + True + DEBUG;TRACE + + + bin\Release\ + False + None + True + False + TRACE + + + + + ..\Gallio\bin\Gallio.dll + + + ..\..\..\bin\ICSharpCode.Core.dll + + + ..\..\..\bin\ICSharpCode.SharpDevelop.dll + + + ..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll + + + ..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll + + + ..\..\..\bin\Tools\NUnit\nunit.framework.dll + + + + + ..\..\..\AddIns\AddIns\Misc\UnitTesting\UnitTesting.dll + + + ..\..\..\bin\UnitTests\UnitTesting.Tests.dll + + + + + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F} + Gallio.Extension + + + {88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC} + Gallio.SharpDevelop + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoApplicationFileNameTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoApplicationFileNameTestFixture.cs new file mode 100644 index 0000000000..a979d1eafa --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoApplicationFileNameTestFixture.cs @@ -0,0 +1,62 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using Gallio.SharpDevelop; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioEchoApplicationFileNameTestFixture + { + GallioEchoConsoleApplication app; + string gallioEchoConsoleFileName; + MockAddInTree addinTree; + string addinTreePath; + + [SetUp] + public void Init() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests tests = new SelectedTests(project); + + gallioEchoConsoleFileName = @"d:\gallio\bin\Gallio.Echo.exe"; + addinTreePath = GallioEchoConsoleApplicationFactory.AddInTreePath; + + addinTree = new MockAddInTree(); + List items = new List(); + items.Add(gallioEchoConsoleFileName); + + addinTree.AddItems(addinTreePath, items); + + GallioEchoConsoleApplicationFactory factory = new GallioEchoConsoleApplicationFactory(addinTree); + app = factory.Create(tests); + } + + [Test] + public void AddInTreeBuildItemsReturnsGallioEchoConsoleFileName() + { + List items = addinTree.BuildItems(addinTreePath, null); + + List expectedItems = new List(); + expectedItems.Add(gallioEchoConsoleFileName); + + Assert.AreEqual(expectedItems.ToArray(), items.ToArray()); + } + + [Test] + public void ApplicationFileNameIsTakenFromAddInTree() + { + string expectedFileName = gallioEchoConsoleFileName; + Assert.AreEqual(expectedFileName, app.FileName); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoCommandLineTests.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoCommandLineTests.cs new file mode 100644 index 0000000000..8c7f50fc9a --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoCommandLineTests.cs @@ -0,0 +1,76 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioEchoCommandLineTests + { + MockCSharpProject project; + SelectedTests selectedTests; + + [SetUp] + public void Init() + { + project = new MockCSharpProject(); + selectedTests = new SelectedTests(project); + } + + [Test] + public void CommandLineIncludesProjectOutputAssembly() + { + GallioEchoConsoleApplication app = new GallioEchoConsoleApplication(selectedTests); + + string expectedArgs = + "/rv:v4.0.30319 " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + + Assert.AreEqual(expectedArgs, app.GetArguments()); + } + + [Test] + public void SharpDevelopTestRunnerExtensionAddedToCommandLine() + { + SharpDevelopTestRunnerExtensionCommandLineArgument arg = + new SharpDevelopTestRunnerExtensionCommandLineArgument(); + arg.TestResultsFileName = @"c:\temp\tmp66.tmp"; + + GallioEchoConsoleApplication app = new GallioEchoConsoleApplication(selectedTests); + app.TestRunnerExtensions.Add(arg); + + string expectedArgs = + "/rv:v4.0.30319 " + + "/re:\"Gallio.Extension.SharpDevelopTestRunnerExtension,Gallio.Extension.dll;c:\\temp\\tmp66.tmp\" " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + + Assert.AreEqual(expectedArgs, app.GetArguments()); + } + + [Test] + public void TestRunnerExtensionWithoutParametersAddedToCommandLine() + { + TestRunnerExtensionCommandLineArgument arg = + new TestRunnerExtensionCommandLineArgument("MyNamespace.MyTestExtension,MyTestRunner.dll"); + + GallioEchoConsoleApplication app = new GallioEchoConsoleApplication(selectedTests); + app.TestRunnerExtensions.Add(arg); + + string expectedArgs = + "/rv:v4.0.30319 " + + "/re:\"MyNamespace.MyTestExtension,MyTestRunner.dll\" " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + + Assert.AreEqual(expectedArgs, app.GetArguments()); + } + + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoConsoleProcessStartInfoTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoConsoleProcessStartInfoTestFixture.cs new file mode 100644 index 0000000000..6885bafd47 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioEchoConsoleProcessStartInfoTestFixture.cs @@ -0,0 +1,85 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.IO; +using Gallio.SharpDevelop; +using Gallio.SharpDevelop.Tests.Utils; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioEchoConsoleProcessStartInfoTestFixture + { + ProcessStartInfo info; + + [TestFixtureSetUp] + public void SetUpFixture() + { + string xml = + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""; + AddIn addin = AddIn.Load(new StringReader(xml)); + addin.Enabled = false; + addin.FileName = @"d:\sharpdevelop\addins\gallio\Gallio.SharpDevelop.dll"; + AddInTree.InsertAddIn(addin); + } + + [SetUp] + public void Init() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests selectedTests = new SelectedTests(project); + GallioEchoConsoleApplication app = new GallioEchoConsoleApplication(selectedTests, @"d:\gallio\Gallio.Echo.exe"); + info = app.GetProcessStartInfo(); + } + + [Test] + public void GallioAddInPathIsConvertedByStringParser() + { + string expectedDirectory = @"d:\sharpdevelop\addins\gallio"; + string actualDirectory = StringParser.Parse("${addinpath:ICSharpCode.Gallio}"); + Assert.AreEqual(expectedDirectory, actualDirectory); + } + + [Test] + public void WorkingDirectoryIsGallioAddInDirectory() + { + string expectedDirectory = @"d:\sharpdevelop\addins\gallio"; + Assert.AreEqual(expectedDirectory, info.WorkingDirectory); + } + + [Test] + public void FileNameIsNUnitConsoleExe() + { + string expectedFileName = @"d:\gallio\Gallio.Echo.exe"; + Assert.AreEqual(expectedFileName, info.FileName); + } + + [Test] + public void CommandLineArgumentsAreNUnitConsoleExeCommandLineArguments() + { + string expectedCommandLine = + "/rv:v4.0.30319 " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + + Assert.AreEqual(expectedCommandLine, info.Arguments); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFailureTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFailureTestFixture.cs new file mode 100644 index 0000000000..17f1959f1c --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFailureTestFixture.cs @@ -0,0 +1,85 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using Gallio.SharpDevelop; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioTestFailureTestFixture + { + GallioTestResult gallioTestResult; + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyNamespace.MyTests"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "Test failed"; + testResult.StackTrace = + @" at GallioTest.MyClass.AssertWithFailureMessage() in d:\temp\test\..\GallioTest\MyClass.cs:line 46"; + gallioTestResult = new GallioTestResult(testResult); + } + + [Test] + public void TestResultTypeIsFailure() + { + Assert.AreEqual(TestResultType.Failure, gallioTestResult.ResultType); + } + + [Test] + public void TestResultMessageIsTestFailed() + { + Assert.AreEqual("Test failed", gallioTestResult.Message); + } + + [Test] + public void TestResultHasStackTrace() + { + string expectedStackTrace = + @" at GallioTest.MyClass.AssertWithFailureMessage() in d:\temp\test\..\GallioTest\MyClass.cs:line 46"; + Assert.AreEqual(expectedStackTrace, gallioTestResult.StackTrace); + } + + [Test] + public void TestResultHasExpectedName() + { + Assert.AreEqual("MyNamespace.MyTests", gallioTestResult.Name); + } + + [Test] + public void StackTraceFilePositionFileNameMatchesLastFileNameInStackTrace() + { + string expectedFileName = @"d:\temp\GallioTest\MyClass.cs"; + Assert.AreEqual(expectedFileName, gallioTestResult.StackTraceFilePosition.FileName); + } + + [Test] + public void StackTraceFilePositionLineNumberIs46WhichIsEqualToReportedErrorLine() + { + Assert.AreEqual(46, gallioTestResult.StackTraceFilePosition.Line); + } + + [Test] + public void StackTraceFilePositionColumnNumberIsOne() + { + Assert.AreEqual(1, gallioTestResult.StackTraceFilePosition.Column); + } + + [Test] + public void ChangingStackTraceToEmptyStringSetsStackTraceFilePositionToEmpty() + { + gallioTestResult.StackTraceFilePosition = new FilePosition("test.cs", 10, 2); + gallioTestResult.StackTrace = String.Empty; + Assert.IsTrue(gallioTestResult.StackTraceFilePosition.IsEmpty); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestClassTests.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestClassTests.cs new file mode 100644 index 0000000000..5ce3a919a6 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestClassTests.cs @@ -0,0 +1,91 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using Gallio.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioTestFrameworkIsTestClassTests + { + GallioTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new GallioTestFramework(); + } + + [Test] + public void IsTestClassReturnsFalseHasClassHasNoAttributes() + { + MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); + Assert.IsFalse(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsTrueHasClassHasTestFixtureAttributeMissingAttributePart() + { + MockAttribute testAttribute = new MockAttribute("TestFixture"); + MockClass mockClass = MockClass.CreateMockClassWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsTrueHasClassHasTestFixtureAttribute() + { + MockAttribute testFixtureAttribute = new MockAttribute("TestFixtureAttribute"); + MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute); + Assert.IsTrue(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsTrueHasClassHasFullyQualifiedNUnitTestFixtureAttribute() + { + MockAttribute testFixtureAttribute = new MockAttribute("MbUnit.Framework.TestFixtureAttribute"); + MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute); + Assert.IsTrue(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsFalseWhenClassIsNull() + { + Assert.IsFalse(testFramework.IsTestClass(null)); + } + + [Test] + public void IsTestClassReturnsFalseWhenProjectContentLanguageIsNull() + { + IProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + MockClass mockClass = new MockClass(mockProjectContent); + + Assert.IsFalse(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsFalseWhenProjectContentLanguageNameComparerIsNull() + { + IProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + mockProjectContent.Language = new LanguageProperties(null); + MockClass mockClass = new MockClass(mockProjectContent); + mockClass.Attributes.Add(new MockAttribute("Test")); + + Assert.IsFalse(testFramework.IsTestClass(mockClass)); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestMethodTests.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestMethodTests.cs new file mode 100644 index 0000000000..50c33d231b --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestMethodTests.cs @@ -0,0 +1,127 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using Gallio.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioTestFrameworkIsTestMethodTests + { + GallioTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new GallioTestFramework(); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasNoAttributes() + { + MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeWithoutAttributePart() + { + MockAttribute testAttribute = new MockAttribute("Test"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeAttribute() + { + MockAttribute testAttribute = new MockAttribute("TestAttribute"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsTrueWhenMethodHasFullyQualifiedNUnitTestAttribute() + { + MockAttribute testAttribute = new MockAttribute("MbUnit.Framework.TestAttribute"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodIsNull() + { + Assert.IsFalse(testFramework.IsTestMethod(null)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenProjectContentLanguageHasNullNameComparer() + { + IProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + mockProjectContent.Language = new LanguageProperties(null); + MockClass mockClass = new MockClass(mockProjectContent); + MockMethod mockMethod = new MockMethod(mockClass); + mockMethod.Attributes.Add(new MockAttribute("Test")); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + /// + /// Even if the project is null the method should be + /// flagged as a TestMethod. + /// + [Test] + public void IsTestMethodReturnsTrueWhenProjectIsNull() + { + MockAttribute testAttribute = new MockAttribute("Test"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent; + mockProjectContent.Project = null; + + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasNullDeclaringType() + { + MockMethod mockMethod = new MockMethod(new MockClass()); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasNullLanguage() + { + IProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + MockClass mockClass = new MockClass(mockProjectContent); + MockMethod mockMethod = new MockMethod(mockClass); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasHasParameters() + { + MockAttribute testAttribute = new MockAttribute("Test"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + MockParameter mockParameter = new MockParameter(); + mockMethod.Parameters.Add(mockParameter); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestProjectTests.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestProjectTests.cs new file mode 100644 index 0000000000..b6314232ea --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestFrameworkIsTestProjectTests.cs @@ -0,0 +1,97 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.SharpDevelop; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioTestFrameworkIsTestProjectTests + { + GallioTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new GallioTestFramework(); + } + + [Test] + public void GallioTestFrameworkImplementsITestFramework() + { + Assert.IsNotNull(testFramework as ITestFramework); + } + + [Test] + public void IsTestProjectReturnsFalseForNullProject() + { + Assert.IsFalse(testFramework.IsTestProject(null)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithMbUnitFrameworkAssemblyReference() + { + MockCSharpProject project = new MockCSharpProject(); + + ReferenceProjectItem systemRef = new ReferenceProjectItem(project, "System"); + ProjectService.AddProjectItem(project, systemRef); + + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "MbUnit"); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsFalseForProjectWithoutMbUnitFrameworkAssemblyReference() + { + MockCSharpProject project = new MockCSharpProject(); + Assert.IsFalse(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithMbUnitFrameworkAssemblyReferenceIgnoringCase() + { + MockCSharpProject project = new MockCSharpProject(); + + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "MBUNIT"); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithMbUnitFrameworkAssemblyReferenceIgnoringNonReferenceProjectItems() + { + MockCSharpProject project = new MockCSharpProject(); + + FileProjectItem fileItem = new FileProjectItem(project, ItemType.Compile, "test.cs"); + ProjectService.AddProjectItem(project, fileItem); + + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "mbunit"); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithMbUnitFrameworkAssemblyReferenceUsingFullName() + { + MockCSharpProject project = new MockCSharpProject(); + string assemblyName = "mbunit, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"; + ReferenceProjectItem mbunitFrameworkRef = new ReferenceProjectItem(project, assemblyName); + ProjectService.AddProjectItem(project, mbunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestToSharpDevelopTestResultConversionTests.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestToSharpDevelopTestResultConversionTests.cs new file mode 100644 index 0000000000..6c295880c6 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/GallioTestToSharpDevelopTestResultConversionTests.cs @@ -0,0 +1,155 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Model = Gallio.Model; +using Gallio.Extension; +using Gallio.Runner.Events; +using Gallio.SharpDevelop; +using Gallio.SharpDevelop.Tests.Utils; +using NUnit.Framework; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class GallioTestToSharpDevelopTestResultConversionTests + { + GallioTestStepFinishedEventArgsFactory factory; + TestStepFinishedEventArgs testStepEventArgs; + GallioTestStepConverter converter; + TestResult testResult; + + [SetUp] + public void Init() + { + factory = new GallioTestStepFinishedEventArgsFactory(); + } + + [Test] + public void GallioTestNameIsConvertedToSharpDevelopTestName() + { + string gallioTestName = "MyNamespace/MyClass/MyTestMethod"; + CreateGallioTestStepEventArgs(gallioTestName); + ConvertToSharpDevelopTestResult(); + + string expectedTestName = "MyNamespace.MyClass.MyTestMethod"; + Assert.AreEqual(expectedTestName, testResult.Name); + } + + void CreateGallioTestStepEventArgs(string testName) + { + testStepEventArgs = factory.Create(testName); + } + + void ConvertToSharpDevelopTestResult() + { + converter = new GallioTestStepConverter(testStepEventArgs); + testResult = converter.GetTestResult(); + } + + [Test] + public void GallioTestOutcomePassedIsConvertedToSharpDevelopTestSuccess() + { + CreateGallioTestStepEventArgs(); + UpdateGallioTestOutcomeToPassed(); + ConvertToSharpDevelopTestResult(); + + Assert.AreEqual(TestResultType.Success, testResult.ResultType); + } + + void CreateGallioTestStepEventArgs() + { + CreateGallioTestStepEventArgs("MyNamespace.MyClass.MyTest"); + } + + void UpdateGallioTestOutcomeToPassed() + { + UpdateGallioTestOutcome(Model.TestOutcome.Passed); + } + + void UpdateGallioTestOutcome(Model.TestOutcome testOutcome) + { + testStepEventArgs.TestStepRun.Result.Outcome = testOutcome; + } + + [Test] + public void GallioTestOutcomeErrorIsConvertedToSharpDevelopTestFailure() + { + CreateGallioTestStepEventArgs(); + UpdateGallioTestOutcomeToError(); + ConvertToSharpDevelopTestResult(); + + Assert.AreEqual(TestResultType.Failure, testResult.ResultType); + } + + void UpdateGallioTestOutcomeToError() + { + UpdateGallioTestOutcome(Model.TestOutcome.Error); + } + + [Test] + public void GallioTestOutcomeSkippedIsConvertedToSharpDevelopTestIgnored() + { + CreateGallioTestStepEventArgs(); + UpdateGallioTestOutcomeToSkipped(); + ConvertToSharpDevelopTestResult(); + + Assert.AreEqual(TestResultType.Ignored, testResult.ResultType); + } + + void UpdateGallioTestOutcomeToSkipped() + { + UpdateGallioTestOutcome(Model.TestOutcome.Skipped); + } + + [Test] + public void GallioTestOutcomeInconclusiveIsConvertedToSharpDevelopTestIgnored() + { + CreateGallioTestStepEventArgs(); + UpdateGallioTestOutcomeToInconclusive(); + ConvertToSharpDevelopTestResult(); + + Assert.AreEqual(TestResultType.Ignored, testResult.ResultType); + } + + void UpdateGallioTestOutcomeToInconclusive() + { + UpdateGallioTestOutcome(Model.TestOutcome.Inconclusive); + } + + [Test] + public void GallioAssertionFailureMessageIsConvertedToSharpDevelopTestResultMessage() + { + CreateGallioTestStepEventArgs(); + UpdateGallioTestOutcomeToError(); + UpdateGallioTestLogWithAssertionFailure(); + ConvertToSharpDevelopTestResult(); + + string expectedMessage = "Expected value to be true. User assertion message."; + Assert.AreEqual(expectedMessage, testResult.Message); + } + + void UpdateGallioTestLogWithAssertionFailure() + { + GallioBodyTagFactory factory = new GallioBodyTagFactory(); + testStepEventArgs.TestStepRun.TestLog.Streams.Add(factory.CreateAssertionFailureStructuredStream()); + } + + [Test] + public void GallioAssertionFailureStackTraceIsConvertedToSharpDevelopTestResultStackTrace() + { + CreateGallioTestStepEventArgs(); + UpdateGallioTestOutcomeToError(); + UpdateGallioTestLogWithAssertionFailure(); + ConvertToSharpDevelopTestResult(); + + string expectedStackTrace = + @" at GallioTest.MyClass.AssertWithFailureMessage() in d:\temp\test\GallioTest\MyClass.cs:line 46 "; + Assert.AreEqual(expectedStackTrace, testResult.StackTrace); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/TestResultsWriterTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/TestResultsWriterTestFixture.cs new file mode 100644 index 0000000000..505cd93e81 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/TestResultsWriterTestFixture.cs @@ -0,0 +1,126 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; +using Gallio.Extension; +using NUnit.Framework; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class TestResultsWriterTestFixture + { + TestResultsWriter writer; + StringBuilder results; + + [SetUp] + public void Init() + { + results = new StringBuilder(); + StringWriter stringWriter = new StringWriter(results); + writer = new TestResultsWriter(stringWriter); + } + + [TearDown] + public void TearDown() + { + writer.Dispose(); + } + + [Test] + public void WriteSuccessTestResult() + { + TestResult testResult = new TestResult("MyTests.MyTestClass.MyTestMethod"); + testResult.ResultType = TestResultType.Success; + writer.Write(testResult); + + string expectedText = + "Name: MyTests.MyTestClass.MyTestMethod\r\n" + + "Result: Success\r\n"; + + Assert.AreEqual(expectedText, results.ToString()); + } + + [Test] + public void WriteIgnoredTestResult() + { + TestResult testResult = new TestResult("MyTests.MyTestClass.MyTestMethod"); + testResult.ResultType = TestResultType.Ignored; + writer.Write(testResult); + + string expectedText = + "Name: MyTests.MyTestClass.MyTestMethod\r\n" + + "Result: Ignored\r\n"; + + Assert.AreEqual(expectedText, results.ToString()); + } + + [Test] + public void WriteFailedTestResult() + { + TestResult testResult = new TestResult("MyTests.MyTestClass.MyTestMethod"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "message"; + testResult.StackTrace = "stacktrace"; + writer.Write(testResult); + + string expectedText = + "Name: MyTests.MyTestClass.MyTestMethod\r\n" + + "Result: Failure\r\n" + + "Message: message\r\n" + + "StackTrace: stacktrace\r\n"; + + Assert.AreEqual(expectedText, results.ToString()); + } + + [Test] + public void WriteFailedTestResultWithTwoLineMessage() + { + TestResult testResult = new TestResult("MyTests.MyTestClass.MyTestMethod"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "first\r\n" + + "second"; + testResult.StackTrace = "stacktrace"; + writer.Write(testResult); + + string expectedText = + "Name: MyTests.MyTestClass.MyTestMethod\r\n" + + "Result: Failure\r\n" + + "Message: first\r\n" + + " second\r\n" + + "StackTrace: stacktrace\r\n"; + + Assert.AreEqual(expectedText, results.ToString()); + } + + [Test] + public void WriteFailedTestResultWithThreeLineStackTrace() + { + TestResult testResult = new TestResult("MyTests.MyTestClass.MyTestMethod"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "first\r\n" + + "second\r\n"; + testResult.StackTrace = "first\r\n" + + "second\r\n" + + "third\r\n"; + writer.Write(testResult); + + string expectedText = + "Name: MyTests.MyTestClass.MyTestMethod\r\n" + + "Result: Failure\r\n" + + "Message: first\r\n" + + " second\r\n" + + "StackTrace: first\r\n" + + " second\r\n" + + " third\r\n"; + + Assert.AreEqual(expectedText, results.ToString()); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/TestRunnerExtensionTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/TestRunnerExtensionTestFixture.cs new file mode 100644 index 0000000000..6719b90d35 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/TestRunnerExtensionTestFixture.cs @@ -0,0 +1,71 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Extension; +using Gallio.Runtime.Logging; +using Gallio.SharpDevelop.Tests.Utils; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace Gallio.SharpDevelop.Tests +{ + [TestFixture] + public class TestRunnerExtensionTestFixture + { + SharpDevelopTestRunnerExtension testRunnerExtension; + MockTestResultsWriterFactory factory; + MockTestRunnerEvents testRunnerEvents; + MockTestResultsWriter writer; + NullLogger logger; + + [SetUp] + public void Init() + { + testRunnerEvents = new MockTestRunnerEvents(); + logger = new NullLogger(); + factory = new MockTestResultsWriterFactory(); + + testRunnerExtension = new SharpDevelopTestRunnerExtension(factory); + testRunnerExtension.Parameters = @"c:\temp\tmp77.tmp"; + testRunnerExtension.Install(testRunnerEvents, logger); + + writer = factory.TestResultsWriter; + } + + [Test] + public void TestResultWriterCreatedWithFileNameTakenFromTestRunnerExtensionParameters() + { + string expectedFileName = @"c:\temp\tmp77.tmp"; + Assert.AreEqual(expectedFileName, writer.FileName); + } + + [Test] + public void FiringTestStepFinishedEventWritesTestResultNameToTestResultsWriter() + { + string testName = "MyNamespace.MyTests.MyTestMethod"; + testRunnerEvents.FireTestStepFinishedEvent("MyNamespace.MyTests.MyTestMethod"); + + Assert.AreEqual(testName, writer.FirstTestResult.Name); + } + + [Test] + public void TestRunnerEventsDisposeStartedEventCausesTestResultsWriterToBeDisposed() + { + testRunnerEvents.FireDisposeStartedEvent(); + Assert.IsTrue(writer.IsDisposed); + } + + [Test] + public void FiringTestStepFinishedEventWithNonTestCaseDoesNotWriteTestResultToTestResultsWriter() + { + testRunnerEvents.FireTestStepFinishedEventForNonTestCase("MyNamespace.MyTests.MyTestMethod"); + + Assert.AreEqual(0, writer.TestResults.Count); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/GallioBodyTagFactory.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/GallioBodyTagFactory.cs new file mode 100644 index 0000000000..bea5cdc90b --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/GallioBodyTagFactory.cs @@ -0,0 +1,93 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Model; +using Gallio.Common.Markup; +using Gallio.Common.Markup.Tags; +using Gallio.Common.Reflection; + +namespace Gallio.SharpDevelop.Tests.Utils +{ + public class GallioBodyTagFactory + { + public StructuredStream CreateAssertionFailureStructuredStream() + { + StructuredStream stream = new StructuredStream("Failures"); + stream.Body = CreateAssertionFailure(); + return stream; + } + + public BodyTag CreateAssertionFailure() + { + BodyTag bodyTag = new BodyTag(); + bodyTag.Contents.Add(CreateAssertionFailureMarkerTag()); + return bodyTag; + } + + MarkerTag CreateAssertionFailureMarkerTag() + { + MarkerTag markerTag = new MarkerTag(Marker.AssertionFailure); + markerTag.Contents.Add(CreateAssertionFailureSectionTag()); + return markerTag; + } + + SectionTag CreateAssertionFailureSectionTag() + { + SectionTag sectionTag = new SectionTag("Expected value to be true."); + sectionTag.Contents.Add(CreateUserAssertionMessageTextTag()); + sectionTag.Contents.Add(CreateMonospaceMarkerTag()); + sectionTag.Contents.Add(CreateEmptyTextTag()); + sectionTag.Contents.Add(CreateStackTraceMarkerTag()); + return sectionTag; + } + + TextTag CreateUserAssertionMessageTextTag() + { + return new TextTag("User assertion message."); + } + + MarkerTag CreateMonospaceMarkerTag() + { + return new MarkerTag(Marker.Monospace); + } + + TextTag CreateEmptyTextTag() + { + return new TextTag(String.Empty); + } + + MarkerTag CreateStackTraceMarkerTag() + { + MarkerTag markerTag = new MarkerTag(Marker.StackTrace); + markerTag.Contents.Add(CreateStackTraceTextTag()); + markerTag.Contents.Add(CreateCodeLocationMarkerTag()); + return markerTag; + } + + TextTag CreateStackTraceTextTag() + { + string text = " at GallioTest.MyClass.AssertWithFailureMessage() in "; + return new TextTag(text); + } + + MarkerTag CreateCodeLocationMarkerTag() + { + CodeLocation location = new CodeLocation(); + Marker marker = Marker.CodeLocation(location); + MarkerTag markerTag = new MarkerTag(marker); + markerTag.Contents.Add(CreateCodeLocationTextTag()); + return markerTag; + } + + TextTag CreateCodeLocationTextTag() + { + string text = @"d:\temp\test\GallioTest\MyClass.cs:line 46 "; + return new TextTag(text); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/GallioTestStepFinishedEventArgsFactory.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/GallioTestStepFinishedEventArgsFactory.cs new file mode 100644 index 0000000000..0a3bc5856c --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/GallioTestStepFinishedEventArgsFactory.cs @@ -0,0 +1,52 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using Gallio.Model.Schema; +using Gallio.Runner.Events; +using Gallio.Runner.Reports.Schema; + +namespace Gallio.SharpDevelop.Tests.Utils +{ + public class GallioTestStepFinishedEventArgsFactory + { + TestData gallioTest; + Report gallioReport = new Report(); + TestStepRun gallioTestStepRun; + + public TestStepFinishedEventArgs Create(string name) + { + CreateTestData(name); + CreateTestStepRun(); + return CreateTestStepFinishedEventArgs(); + } + + void CreateTestData(string name) + { + string gallioTestName = ConvertToGallioTestName(name); + gallioTest = new TestData("a", "b", gallioTestName); + gallioTest.IsTestCase = true; + } + + void CreateTestStepRun() + { + TestStepData testStepData = new TestStepData("a", "b", "c", "d"); + gallioTestStepRun = new TestStepRun(testStepData); + } + + string ConvertToGallioTestName(string name) + { + return name.Replace('.', '/'); + } + + TestStepFinishedEventArgs CreateTestStepFinishedEventArgs() + { + return new TestStepFinishedEventArgs(gallioReport, gallioTest, gallioTestStepRun); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestResultsWriter.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestResultsWriter.cs new file mode 100644 index 0000000000..a04455014e --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestResultsWriter.cs @@ -0,0 +1,52 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Extension; +using System.Collections.Generic; + +namespace Gallio.SharpDevelop.Tests.Utils +{ + public class MockTestResultsWriter : ITestResultsWriter + { + string fileName = String.Empty; + List testResults = new List(); + bool disposed; + + public MockTestResultsWriter(string fileName) + { + this.fileName = fileName; + } + + public string FileName { + get { return fileName; } + } + + public void Write(TestResult testResult) + { + testResults.Add(testResult); + } + + public List TestResults { + get { return testResults; } + } + + public TestResult FirstTestResult { + get { return testResults[0]; } + } + + public void Dispose() + { + disposed = true; + } + + public bool IsDisposed { + get { return disposed; } + set { disposed = value; } + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestResultsWriterFactory.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestResultsWriterFactory.cs new file mode 100644 index 0000000000..7e519d69d9 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestResultsWriterFactory.cs @@ -0,0 +1,28 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Extension; +using Gallio.SharpDevelop; + +namespace Gallio.SharpDevelop.Tests.Utils +{ + public class MockTestResultsWriterFactory : ITestResultsWriterFactory + { + MockTestResultsWriter testResultsWriter; + + public ITestResultsWriter Create(string fileName) + { + testResultsWriter = new MockTestResultsWriter(fileName); + return testResultsWriter; + } + + public MockTestResultsWriter TestResultsWriter { + get { return testResultsWriter; } + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestRunnerEvents.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestRunnerEvents.cs new file mode 100644 index 0000000000..72dcb19efd --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/MockTestRunnerEvents.cs @@ -0,0 +1,76 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using Gallio.Runner.Events; + +namespace Gallio.SharpDevelop.Tests.Utils +{ + public class MockTestRunnerEvents : ITestRunnerEvents + { + #pragma warning disable 67 + + public event EventHandler LogEntrySubmitted; + public event EventHandler MessageReceived; + public event EventHandler InitializeStarted; + public event EventHandler InitializeFinished; + public event EventHandler DisposeStarted; + public event EventHandler DisposeFinished; + public event EventHandler ExploreStarted; + public event EventHandler ExploreFinished; + public event EventHandler RunStarted; + public event EventHandler RunFinished; + public event EventHandler TestDiscovered; + public event EventHandler AnnotationDiscovered; + public event EventHandler TestStepStarted; + public event EventHandler TestStepFinished; + public event EventHandler TestStepLifecyclePhaseChanged; + public event EventHandler TestStepMetadataAdded; + public event EventHandler TestStepLogAttach; + public event EventHandler TestStepLogStreamWrite; + public event EventHandler TestStepLogStreamEmbed; + public event EventHandler TestStepLogStreamBeginSectionBlock; + public event EventHandler TestStepLogStreamBeginMarkerBlock; + public event EventHandler TestStepLogStreamEndBlock; + + #pragma warning restore 67 + + public void FireTestStepFinishedEvent(string name) + { + TestStepFinishedEventArgs e = CreateTestStepFinishedEventArgs(name); + FireTestStepFinishedEvent(e); + } + + TestStepFinishedEventArgs CreateTestStepFinishedEventArgs(string testName) + { + GallioTestStepFinishedEventArgsFactory factory = new GallioTestStepFinishedEventArgsFactory(); + return factory.Create(testName); + } + + void FireTestStepFinishedEvent(TestStepFinishedEventArgs e) + { + if (TestStepFinished != null) { + TestStepFinished(this, e); + } + } + + public void FireTestStepFinishedEventForNonTestCase(string testName) + { + TestStepFinishedEventArgs e = CreateTestStepFinishedEventArgs(testName); + e.Test.IsTestCase = false; + FireTestStepFinishedEvent(e); + } + + public void FireDisposeStartedEvent() + { + if (DisposeStarted != null) { + DisposeStarted(this, new DisposeStartedEventArgs()); + } + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/CreateAssertionFailureBodyTagTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/CreateAssertionFailureBodyTagTestFixture.cs new file mode 100644 index 0000000000..1e0f85b3ad --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/CreateAssertionFailureBodyTagTestFixture.cs @@ -0,0 +1,175 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Common.Markup; +using Gallio.Common.Markup.Tags; +using Gallio.SharpDevelop.Tests.Utils; +using NUnit.Framework; + +namespace Gallio.SharpDevelop.Tests.Utils.Tests +{ + [TestFixture] + public class CreateAssertionFailureBodyTagTestFixture + { + StructuredStream structuredStream; + BodyTag bodyTag; + MarkerTag assertionFailureMarkerTag; + SectionTag expectedValueToBeTrueSectionTag; + TextTag expectedValueToBeTrueTextTag; + MarkerTag monoSpaceMarkerTag; + TextTag textTagAfterMonoSpaceMarkerTag; + MarkerTag stackTraceMarkerTag; + TextTag stackTraceTextTag; + MarkerTag codeLocationMarkerTag; + TextTag codeLocationTextTag; + + [SetUp] + public void Init() + { + GallioBodyTagFactory factory = new GallioBodyTagFactory(); + structuredStream = factory.CreateAssertionFailureStructuredStream(); + bodyTag = structuredStream.Body; + assertionFailureMarkerTag = GetFirstChildMarkerTag(bodyTag); + expectedValueToBeTrueSectionTag = GetFirstChildSectionTag(assertionFailureMarkerTag); + expectedValueToBeTrueTextTag = GetFirstChildTextTag(expectedValueToBeTrueSectionTag); + monoSpaceMarkerTag = GetSecondChildMarkerTag(expectedValueToBeTrueSectionTag); + textTagAfterMonoSpaceMarkerTag = GetThirdChildTextTag(expectedValueToBeTrueSectionTag); + stackTraceMarkerTag = GetFourthChildMarkerTag(expectedValueToBeTrueSectionTag); + stackTraceTextTag = GetFirstChildTextTag(stackTraceMarkerTag); + codeLocationMarkerTag = GetSecondChildMarkerTag(stackTraceMarkerTag); + codeLocationTextTag = GetFirstChildTextTag(codeLocationMarkerTag); + } + + MarkerTag GetFirstChildMarkerTag(ContainerTag parentTag) + { + return GetFirstChildTag(parentTag) as MarkerTag; + } + + Tag GetFirstChildTag(ContainerTag parentTag) + { + return GetChildTagAtPosition(parentTag, 1); + } + + Tag GetChildTagAtPosition(ContainerTag parentTag, int position) + { + if (TagHasChildTagAtPosition(parentTag, position)) { + int index = position - 1; + return parentTag.Contents[index]; + } + return null; + } + + bool TagHasChildTagAtPosition(ContainerTag tag, int position) + { + if (tag != null) { + return tag.Contents.Count >= position; + } + return false; + } + + SectionTag GetFirstChildSectionTag(ContainerTag parentTag) + { + return GetFirstChildTag(parentTag) as SectionTag; + } + + TextTag GetFirstChildTextTag(ContainerTag parentTag) + { + return GetFirstChildTag(parentTag) as TextTag; + } + + MarkerTag GetSecondChildMarkerTag(ContainerTag parentTag) + { + return GetSecondChildTag(parentTag) as MarkerTag; + } + + Tag GetSecondChildTag(ContainerTag parentTag) + { + return GetChildTagAtPosition(parentTag, 2); + } + + TextTag GetThirdChildTextTag(ContainerTag parentTag) + { + return GetChildTagAtPosition(parentTag, 3) as TextTag; + } + + MarkerTag GetFourthChildMarkerTag(ContainerTag parentTag) + { + return GetChildTagAtPosition(parentTag, 4) as MarkerTag; + } + + [Test] + public void StructuredStreamNameIsFailures() + { + Assert.AreEqual("Failures", structuredStream.Name); + } + + [Test] + public void BodyTagHasOneChildTag() + { + Assert.AreEqual(1, bodyTag.Contents.Count); + } + + [Test] + public void BodyTagChildIsMarkerTagWithClassSetToAssertionFailure() + { + Assert.AreEqual("AssertionFailure", assertionFailureMarkerTag.Class); + } + + [Test] + public void AssertionFailureMarkerTagHasSectionTagContentsWithTagNameEqualToExpectedValueToBeTrue() + { + string expectedName = "Expected value to be true."; + Assert.AreEqual(expectedName, expectedValueToBeTrueSectionTag.Name); + } + + [Test] + public void ExpectedValueToBeTrueSectionTagHasTextTagChildWithTextSetToUserAssertionMessage() + { + string expectedText = "User assertion message."; + Assert.AreEqual(expectedText, expectedValueToBeTrueTextTag.Text); + } + + [Test] + public void ExpectedValueToBeTrueSectionTagHasMarkerTagChildWithClassSetToMonospace() + { + Assert.AreEqual("Monospace", monoSpaceMarkerTag.Class); + } + + [Test] + public void ExpectedValueToBeTrueSectionTagHasTextTagChildAfterMonospaceTagChild() + { + Assert.IsNotNull(textTagAfterMonoSpaceMarkerTag); + } + + [Test] + public void ExpectedValueToBeTrueSectionTagHasMarkerTagWithClassSetToStackTrace() + { + Assert.AreEqual("StackTrace", stackTraceMarkerTag.Class); + } + + [Test] + public void StackTraceTagHasFirstChildTextTagWithFirstLineOfStackTrace() + { + string expectedText = " at GallioTest.MyClass.AssertWithFailureMessage() in "; + Assert.AreEqual(expectedText, stackTraceTextTag.Text); + } + + [Test] + public void StackTraceTagHasMarkerTagChildWithClassSetToCodeLocation() + { + Assert.AreEqual("CodeLocation", codeLocationMarkerTag.Class); + } + + [Test] + public void CodeLocationMarkerHasTextTagWithCodeLocationText() + { + string expectedText = @"d:\temp\test\GallioTest\MyClass.cs:line 46 "; + Assert.AreEqual(expectedText, codeLocationTextTag.Text); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/MockTestResultsWriterFactoryTests.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/MockTestResultsWriterFactoryTests.cs new file mode 100644 index 0000000000..42f1b70cfd --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/MockTestResultsWriterFactoryTests.cs @@ -0,0 +1,82 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Extension; +using Gallio.SharpDevelop.Tests.Utils; +using NUnit.Framework; + +namespace Gallio.SharpDevelop.Tests.Utils.Tests +{ + [TestFixture] + public class MockTestResultsWriterFactoryTests + { + MockTestResultsWriterFactory factory; + + [SetUp] + public void Init() + { + factory = new MockTestResultsWriterFactory(); + } + + [Test] + public void TestResultsWritersSavedByFactory() + { + ITestResultsWriter writer = factory.Create("testresults.txt"); + Assert.AreEqual(writer, factory.TestResultsWriter); + } + + [Test] + public void TestResultsWriterCreatedIsMockTestResultsWriter() + { + MockTestResultsWriter writer = factory.Create("abc.txt") as MockTestResultsWriter; + Assert.IsNotNull(writer); + } + + [Test] + public void TestResultsWriterCreatedWithFileNamePassedToFactoryCreateMethod() + { + MockTestResultsWriter writer = factory.Create("testresults.txt") as MockTestResultsWriter; + Assert.AreEqual("testresults.txt", writer.FileName); + } + + [Test] + public void TestResultsWriterSavesTestResultsWritten() + { + TestResult firstResult = new TestResult("test1"); + TestResult secondResult = new TestResult("test2"); + MockTestResultsWriter writer = factory.Create("testresults.txt") as MockTestResultsWriter; + writer.Write(firstResult); + writer.Write(secondResult); + + TestResult[] expectedTestResults = new TestResult[] { firstResult, secondResult }; + + Assert.AreEqual(expectedTestResults, writer.TestResults.ToArray()); + } + + [Test] + public void FirstTestResultsWriterReturnsFirstTestResultsWriter() + { + TestResult firstResult = new TestResult("test1"); + TestResult secondResult = new TestResult("test2"); + MockTestResultsWriter writer = factory.Create("testresults.txt") as MockTestResultsWriter; + writer.Write(firstResult); + writer.Write(secondResult); + + Assert.AreEqual(firstResult, writer.FirstTestResult); + } + + [Test] + public void IsDisposedCalledReturnsTrueAfterDisposeMethodCalled() + { + MockTestResultsWriter writer = factory.Create("testresults.txt") as MockTestResultsWriter; + writer.IsDisposed = false; + writer.Dispose(); + Assert.IsTrue(writer.IsDisposed); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/MockTestRunnerEventsTestFixture.cs b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/MockTestRunnerEventsTestFixture.cs new file mode 100644 index 0000000000..80ad46ae04 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.Tests/Utils/Tests/MockTestRunnerEventsTestFixture.cs @@ -0,0 +1,69 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using Gallio.Runner.Events; +using Gallio.SharpDevelop.Tests.Utils; +using NUnit.Framework; + +namespace Gallio.SharpDevelop.Tests.Utils.Tests +{ + [TestFixture] + public class MockTestRunnerEventsTestFixture + { + MockTestRunnerEvents testRunnerEvents; + TestStepFinishedEventArgs testStepFinishedEventArgs; + + [SetUp] + public void Init() + { + testRunnerEvents = new MockTestRunnerEvents(); + testRunnerEvents.TestStepFinished += delegate (object source, TestStepFinishedEventArgs e) { + testStepFinishedEventArgs = e; + }; + } + + [Test] + public void FireTestStepFinishedEventWithTestResultCreatesGallioTestDataWithExpectedFullName() + { + testRunnerEvents.FireTestStepFinishedEvent("MyNamespace/MyTests/MyTestMethod"); + + string expectedFullName = "MyNamespace/MyTests/MyTestMethod"; + string actualFullName = testStepFinishedEventArgs.Test.FullName; + Assert.AreEqual(expectedFullName, actualFullName); + } + + [Test] + public void FireTestStepFinishedEventCreatesGallioTestDataWithIsTestCaseSetToTrue() + { + testRunnerEvents.FireTestStepFinishedEvent("testName"); + + Assert.IsTrue(testStepFinishedEventArgs.Test.IsTestCase); + } + + [Test] + public void FireTestStepFinishedEventForNonTestCaseCreatesGallioTestDataIsTestCaseSetToFalse() + { + testRunnerEvents.FireTestStepFinishedEventForNonTestCase("testName"); + + Assert.IsFalse(testStepFinishedEventArgs.Test.IsTestCase); + } + + [Test] + public void FireDisposeStartedEventTriggersEvent() + { + DisposeStartedEventArgs eventArgs = null; + testRunnerEvents.DisposeStarted += delegate(object sender, DisposeStartedEventArgs e) { + eventArgs = e; + }; + testRunnerEvents.FireDisposeStartedEvent(); + + Assert.IsNotNull(eventArgs); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop.sln b/samples/Gallio/Gallio.SharpDevelop.sln new file mode 100644 index 0000000000..6298d44b22 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.0.0.5840 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gallio.SharpDevelop", "Gallio.SharpDevelop\Gallio.SharpDevelop.csproj", "{88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gallio.SharpDevelop.Tests", "Gallio.SharpDevelop.Tests\Gallio.SharpDevelop.Tests.csproj", "{3F6C539D-DB38-41B4-A5B3-B9A52AE607CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gallio.Extension", "Gallio.Extension\Gallio.Extension.csproj", "{98030C86-7B0F-4813-AC4D-9FFCF00CF81F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC}.Debug|x86.Build.0 = Debug|x86 + {88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC}.Debug|x86.ActiveCfg = Debug|x86 + {88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC}.Release|x86.Build.0 = Release|x86 + {88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC}.Release|x86.ActiveCfg = Release|x86 + {3F6C539D-DB38-41B4-A5B3-B9A52AE607CD}.Debug|x86.Build.0 = Debug|x86 + {3F6C539D-DB38-41B4-A5B3-B9A52AE607CD}.Debug|x86.ActiveCfg = Debug|x86 + {3F6C539D-DB38-41B4-A5B3-B9A52AE607CD}.Release|x86.Build.0 = Release|x86 + {3F6C539D-DB38-41B4-A5B3-B9A52AE607CD}.Release|x86.ActiveCfg = Release|x86 + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F}.Debug|x86.Build.0 = Debug|x86 + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F}.Debug|x86.ActiveCfg = Debug|x86 + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F}.Release|x86.Build.0 = Release|x86 + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F}.Release|x86.ActiveCfg = Release|x86 + EndGlobalSection +EndGlobal diff --git a/samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.addin b/samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.addin new file mode 100644 index 0000000000..a24ea7cf00 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.addin @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.csproj b/samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.csproj new file mode 100644 index 0000000000..77fd1b60ec --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/Gallio.SharpDevelop.csproj @@ -0,0 +1,87 @@ + + + + {88D3DC5E-8A91-4DCE-A785-CC37DE0AA0EC} + Debug + x86 + Library + Gallio.SharpDevelop + Gallio.SharpDevelop + v4.0 + Properties + C:\Users\Matt\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis + False + False + 4 + false + + + x86 + False + Auto + 4194304 + 4096 + + + ..\..\..\AddIns\Samples\Gallio + true + Full + False + False + DEBUG;TRACE + + + ..\..\..\AddIns\Samples\Gallio + false + None + True + False + TRACE + + + + + ..\Gallio\bin\Gallio.dll + + + ..\..\..\bin\ICSharpCode.Core.dll + False + + + ..\..\..\bin\ICSharpCode.SharpDevelop.dll + False + + + ..\..\..\bin\ICSharpCode.SharpDevelop.Dom.dll + False + + + + + ..\..\..\AddIns\AddIns\Misc\UnitTesting\UnitTesting.dll + False + + + + + + + + + + + + + + + + Always + + + + + {98030C86-7B0F-4813-AC4D-9FFCF00CF81F} + Gallio.Extension + + + \ No newline at end of file diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplication.cs b/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplication.cs new file mode 100644 index 0000000000..e2ce0c5ff9 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplication.cs @@ -0,0 +1,96 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Text; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioEchoConsoleApplication + { + string fileName = String.Empty; + SelectedTests selectedTests; + StringBuilder commandLine = new StringBuilder(); + List testRunnerExtensions = + new List(); + + public GallioEchoConsoleApplication(SelectedTests selectedTests, string fileName) + { + this.selectedTests = selectedTests; + this.fileName = fileName; + } + + public GallioEchoConsoleApplication(SelectedTests selectedTests) + : this(selectedTests, String.Empty) + { + } + + public string FileName { + get { return fileName; } + } + + public List TestRunnerExtensions { + get { return testRunnerExtensions; } + } + + public string GetArguments() + { + AppendDotNet4Framework(); + AppendTestRunnerExtensions(); + AppendAssemblyToTest(); + + return commandLine.ToString().TrimEnd(); + } + + void AppendDotNet4Framework() + { + AppendArgument("/rv:v4.0.30319"); + + } + + void AppendTestRunnerExtensions() + { + foreach (TestRunnerExtensionCommandLineArgument arg in testRunnerExtensions) { + AppendArgument(arg.ToString()); + } + } + + void AppendArgument(string argument) + { + commandLine.Append(argument); + commandLine.Append(' '); + } + + void AppendAssemblyToTest() + { + AppendQuoted(selectedTests.Project.OutputAssemblyFullPath); + } + + void AppendQuoted(string argument) + { + commandLine.AppendFormat("\"{0}\"", argument); + } + + public ProcessStartInfo GetProcessStartInfo() + { + ProcessStartInfo startInfo = new ProcessStartInfo(); + startInfo.FileName = fileName; + startInfo.Arguments = GetArguments(); + startInfo.WorkingDirectory = GetWorkingDirectory(); + return startInfo; + } + + string GetWorkingDirectory() + { + return StringParser.Parse("${addinpath:ICSharpCode.Gallio}"); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplicationFactory.cs b/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplicationFactory.cs new file mode 100644 index 0000000000..ddfd79d674 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplicationFactory.cs @@ -0,0 +1,41 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioEchoConsoleApplicationFactory + { + public static readonly string AddInTreePath = "/SharpDevelop/UnitTesting/GallioEchoApplication"; + + string gallioEchoConsoleApplicationFileName = "Gallio.Echo.exe"; + + public GallioEchoConsoleApplicationFactory() + : this(new UnitTestAddInTree()) + { + } + + public GallioEchoConsoleApplicationFactory(IAddInTree addInTree) + { + ReadFileName(addInTree); + } + + void ReadFileName(IAddInTree addInTree) + { + List items = addInTree.BuildItems(AddInTreePath, this); + gallioEchoConsoleApplicationFileName = items[0]; + } + + public GallioEchoConsoleApplication Create(SelectedTests selectedTests) + { + return new GallioEchoConsoleApplication(selectedTests, gallioEchoConsoleApplicationFileName); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplicationProcessStartInfo.cs b/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplicationProcessStartInfo.cs new file mode 100644 index 0000000000..678e732e3a --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioEchoConsoleApplicationProcessStartInfo.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioEchoConsoleApplicationProcessStartInfo + { + ProcessStartInfo processStartInfo = new ProcessStartInfo(); + + public GallioEchoConsoleApplicationProcessStartInfo(SelectedTests selectedTests, string testResultsFileName) + { + GallioEchoConsoleApplicationFactory factory = new GallioEchoConsoleApplicationFactory(); + GallioEchoConsoleApplication app = factory.Create(selectedTests); + SharpDevelopTestRunnerExtensionCommandLineArgument argument = new SharpDevelopTestRunnerExtensionCommandLineArgument(); + argument.TestResultsFileName = testResultsFileName; + app.TestRunnerExtensions.Add(argument); + processStartInfo = app.GetProcessStartInfo(); + } + + public ProcessStartInfo ProcessStartInfo { + get { return processStartInfo; } + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioTestDebugger.cs b/samples/Gallio/Gallio.SharpDevelop/GallioTestDebugger.cs new file mode 100644 index 0000000000..bc3762a7e6 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioTestDebugger.cs @@ -0,0 +1,33 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioTestDebugger : TestDebuggerBase + { + public GallioTestDebugger() + { + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + GallioEchoConsoleApplicationProcessStartInfo startInfo = + new GallioEchoConsoleApplicationProcessStartInfo(selectedTests, base.TestResultsMonitor.FileName); + startInfo.ProcessStartInfo.Arguments += " /d"; + return startInfo.ProcessStartInfo; + } + + protected override TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return new GallioTestResult(testResult); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioTestFramework.cs b/samples/Gallio/Gallio.SharpDevelop/GallioTestFramework.cs new file mode 100644 index 0000000000..b5db880dab --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioTestFramework.cs @@ -0,0 +1,111 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioTestFramework : ITestFramework + { + public GallioTestFramework() + { + } + + public bool IsTestProject(IProject project) + { + if (project != null) { + foreach (ProjectItem projectItem in project.Items) { + ReferenceProjectItem referenceProjectItem = projectItem as ReferenceProjectItem; + if (IsMbUnitFrameworkAssemblyReference(referenceProjectItem)) { + return true; + } + } + } + return false; + } + + bool IsMbUnitFrameworkAssemblyReference(ReferenceProjectItem referenceProjectItem) + { + if (referenceProjectItem != null) { + string name = referenceProjectItem.ShortName; + return name.Equals("MbUnit", StringComparison.OrdinalIgnoreCase); + } + return false; + } + + public ITestRunner CreateTestRunner() + { + return new GallioTestRunner(); + } + + public ITestRunner CreateTestDebugger() + { + return new GallioTestDebugger(); + } + + public bool IsTestClass(IClass c) + { + StringComparer nameComparer = GetNameComparer(c); + if (nameComparer != null) { + MbUnitTestAttributeName testAttributeName = new MbUnitTestAttributeName("TestFixture", nameComparer); + foreach (IAttribute attribute in c.Attributes) { + if (testAttributeName.IsEqual(attribute)) { + return true; + } + } + } + return false; + } + + StringComparer GetNameComparer(IClass c) + { + if (c != null) { + IProjectContent projectContent = c.ProjectContent; + if (projectContent != null) { + LanguageProperties language = projectContent.Language; + if (language != null) { + return language.NameComparer; + } + } + } + return null; + } + + /// + /// Determines whether the method is a test method. A method + /// is considered to be a test method if it contains the NUnit Test attribute. + /// If the method has parameters it cannot be a test method. + /// + public bool IsTestMethod(IMember member) + { + if (member == null) { + return false; + } + + StringComparer nameComparer = GetNameComparer(member.DeclaringType); + if (nameComparer != null) { + MbUnitTestAttributeName testAttribute = new MbUnitTestAttributeName("Test", nameComparer); + foreach (IAttribute attribute in member.Attributes) { + if (testAttribute.IsEqual(attribute)) { + IMethod method = (IMethod)member; + if (method.Parameters.Count == 0) { + return true; + } + } + } + } + return false; + } + + public bool IsBuildNeededBeforeTestRun { + get { return true; } + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioTestResult.cs b/samples/Gallio/Gallio.SharpDevelop/GallioTestResult.cs new file mode 100644 index 0000000000..9d54a3b0ee --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioTestResult.cs @@ -0,0 +1,54 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text.RegularExpressions; +using System.IO; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioTestResult : TestResult + { + public GallioTestResult(TestResult testResult) + : base(testResult.Name) + { + Message = testResult.Message; + ResultType = testResult.ResultType; + StackTrace = testResult.StackTrace; + } + + protected override void OnStackTraceChanged() + { + GetFilePositionFromStackTrace(); + } + + /// + /// Stack trace: + /// at GallioTest.MyClass.AssertWithFailureMessage() in d:\temp\test\..\GallioTest\MyClass.cs:line 46 + /// + void GetFilePositionFromStackTrace() + { + Match match = Regex.Match(StackTrace, @"\sin\s(.*?):line\s(\d+)", RegexOptions.Multiline); + if (match.Success) { + SetStackTraceFilePosition(match.Groups); + } else { + StackTraceFilePosition = FilePosition.Empty; + } + } + + void SetStackTraceFilePosition(GroupCollection groups) + { + string fileName = Path.GetFullPath(groups[1].Value); + int line = Convert.ToInt32(groups[2].Value); + int column = 1; + + StackTraceFilePosition = new FilePosition(fileName, line, column); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/GallioTestRunner.cs b/samples/Gallio/Gallio.SharpDevelop/GallioTestRunner.cs new file mode 100644 index 0000000000..d8686673a3 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/GallioTestRunner.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.UnitTesting; + +namespace Gallio.SharpDevelop +{ + public class GallioTestRunner : TestProcessRunnerBase + { + public GallioTestRunner() + { + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + GallioEchoConsoleApplicationProcessStartInfo startInfo = + new GallioEchoConsoleApplicationProcessStartInfo(selectedTests, base.TestResultsMonitor.FileName); + return startInfo.ProcessStartInfo; + } + + protected override TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return new GallioTestResult(testResult); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/MbUnitTestAttributeName.cs b/samples/Gallio/Gallio.SharpDevelop/MbUnitTestAttributeName.cs new file mode 100644 index 0000000000..5bcc36d6c6 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/MbUnitTestAttributeName.cs @@ -0,0 +1,47 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; + +namespace Gallio.SharpDevelop +{ + public class MbUnitTestAttributeName + { + string name = String.Empty; + string qualifiedName = String.Empty; + string fullyQualifiedName = String.Empty; + StringComparer nameComparer; + + public MbUnitTestAttributeName(string name, StringComparer nameComparer) + { + this.name = name; + this.nameComparer = nameComparer; + qualifiedName = String.Concat(name, "Attribute"); + fullyQualifiedName = String.Concat("MbUnit.Framework.", name, "Attribute"); + } + + /// + /// Determines whether the specified attribute name is a + /// match to this attribute. + /// + public bool IsEqual(string attributeName) + { + if (nameComparer.Equals(attributeName, name) || + nameComparer.Equals(attributeName, qualifiedName) || + nameComparer.Equals(attributeName, fullyQualifiedName)) { + return true; + } + return false; + } + + public bool IsEqual(IAttribute attribute) + { + return IsEqual(attribute.AttributeType.FullyQualifiedName); + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/Properties/AssemblyInfo.cs b/samples/Gallio/Gallio.SharpDevelop/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1f2c22bb80 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/Properties/AssemblyInfo.cs @@ -0,0 +1,31 @@ +#region Using directives + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +#endregion + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Gallio.SharpDevelop")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Gallio.SharpDevelop")] +[assembly: AssemblyCopyright("Copyright 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// This sets the default COM visibility of types in the assembly to invisible. +// If you need to expose a type to COM, use [ComVisible(true)] on that type. +[assembly: ComVisible(false)] + +// The assembly version has following format : +// +// Major.Minor.Build.Revision +// +// You can specify all the values or you can use the default the Revision and +// Build Numbers by using the '*' as shown below: +[assembly: AssemblyVersion("0.1")] diff --git a/samples/Gallio/Gallio.SharpDevelop/SharpDevelopTestRunnerExtensionCommandLineArgument.cs b/samples/Gallio/Gallio.SharpDevelop/SharpDevelopTestRunnerExtensionCommandLineArgument.cs new file mode 100644 index 0000000000..eebf2371b2 --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/SharpDevelopTestRunnerExtensionCommandLineArgument.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System; +using Gallio.Extension; + +namespace Gallio.SharpDevelop +{ + public class SharpDevelopTestRunnerExtensionCommandLineArgument : TestRunnerExtensionCommandLineArgument + { + string testResultsFileName = String.Empty; + + public SharpDevelopTestRunnerExtensionCommandLineArgument() + : base(GetFullyQualifiedTypeName()) + { + } + + static string GetFullyQualifiedTypeName() + { + Type type = typeof(SharpDevelopTestRunnerExtension); + string typeName = type.FullName; + string assemblyFileName = type.Assembly.ManifestModule.ScopeName; + return String.Format("{0},{1}", typeName, assemblyFileName); + } + + public string TestResultsFileName { + get { return testResultsFileName; } + set { + testResultsFileName = value; + Parameters = testResultsFileName; + } + } + } +} diff --git a/samples/Gallio/Gallio.SharpDevelop/TestRunnerExtensionCommandLineArgument.cs b/samples/Gallio/Gallio.SharpDevelop/TestRunnerExtensionCommandLineArgument.cs new file mode 100644 index 0000000000..6978b4c41f --- /dev/null +++ b/samples/Gallio/Gallio.SharpDevelop/TestRunnerExtensionCommandLineArgument.cs @@ -0,0 +1,51 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace Gallio.SharpDevelop +{ + public class TestRunnerExtensionCommandLineArgument + { + string type; + string parameters = String.Empty; + + public TestRunnerExtensionCommandLineArgument(string type) + { + this.type = type; + } + + public string Type { + get { return type; } + } + + public string Parameters { + get { return parameters; } + set { parameters = value; } + } + + public override string ToString() + { + return String.Format("/re:\"{0}{1}\"", + GetTypeName(), + GetParameters()); + } + + string GetTypeName() + { + return type; + } + + string GetParameters() + { + if (String.IsNullOrEmpty(parameters)) { + return String.Empty; + } + return String.Format(";{0}", parameters); + } + } +} diff --git a/samples/Gallio/readme.rtf b/samples/Gallio/readme.rtf new file mode 100644 index 0000000000..c62ad1b501 Binary files /dev/null and b/samples/Gallio/readme.rtf differ diff --git a/src/AddIns/Analysis/CodeAnalysis/CodeAnalysis.addin b/src/AddIns/Analysis/CodeAnalysis/CodeAnalysis.addin index 043ef5de48..58d7b202cd 100644 --- a/src/AddIns/Analysis/CodeAnalysis/CodeAnalysis.addin +++ b/src/AddIns/Analysis/CodeAnalysis/CodeAnalysis.addin @@ -32,14 +32,11 @@ - - - - + - + diff --git a/src/AddIns/Analysis/CodeCoverage/CodeCoverage.sln b/src/AddIns/Analysis/CodeCoverage/CodeCoverage.sln index c301e3d780..ab0cca6e98 100644 --- a/src/AddIns/Analysis/CodeCoverage/CodeCoverage.sln +++ b/src/AddIns/Analysis/CodeCoverage/CodeCoverage.sln @@ -1,15 +1,13 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# SharpDevelop 3.0.0.3280 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.0.0.5879 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage", "Project\CodeCoverage.csproj", "{08CE9972-283B-44F4-82FA-966F7DFA6B7A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeCoverage.Tests", "Test\CodeCoverage.Tests.csproj", "{A5C0E8F8-9D04-46ED-91D6-1DEF1575313B}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TextEditor", "..\..\..\Libraries\ICSharpCode.TextEditor\Project\ICSharpCode.TextEditor.csproj", "{2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" @@ -22,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Wi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Dom", "..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj", "{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.AvalonEdit", "..\..\..\Libraries\AvalonEdit\ICSharpCode.AvalonEdit\ICSharpCode.AvalonEdit.csproj", "{6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -40,10 +40,6 @@ Global {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.Build.0 = Release|Any CPU {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.Build.0 = Release|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.ActiveCfg = Release|Any CPU {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU @@ -68,5 +64,9 @@ Global {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.Build.0 = Release|Any CPU {924EE450-603D-49C1-A8E5-4AFAA31CE6F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.Build.0 = Release|Any CPU + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj b/src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj index 36bc56a60c..cd1865dbd2 100644 --- a/src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj +++ b/src/AddIns/Analysis/CodeCoverage/Project/CodeCoverage.csproj @@ -1,4 +1,5 @@ - + + Library ICSharpCode.CodeCoverage @@ -37,14 +38,23 @@ 3.0 + + 3.0 + + + 4.0 + 3.0 + + 3.0 + @@ -93,9 +103,9 @@ - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor + + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} + ICSharpCode.AvalonEdit False diff --git a/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs b/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs index f10e57dbe3..020778ac3b 100644 --- a/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs +++ b/src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageControl.cs @@ -5,14 +5,17 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using System; using System.Collections.Generic; using System.Windows.Forms; +using System.Windows.Forms.Integration; +using ICSharpCode.AvalonEdit; +using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.Core; using ICSharpCode.Core.WinForms; using ICSharpCode.SharpDevelop; -using ICSharpCode.TextEditor; +using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; +using ICSharpCode.SharpDevelop.Editor.AvalonEdit; namespace ICSharpCode.CodeCoverage { @@ -22,7 +25,9 @@ namespace ICSharpCode.CodeCoverage ListView listView; SplitContainer verticalSplitContainer; SplitContainer horizontalSplitContainer; - TextEditorControl textEditorControl; + ElementHost textEditorHost; + TextEditor textEditor; + string textEditorFileName; ColumnHeader visitCountColumnHeader; ColumnHeader startLineColumnHeader; ColumnHeader endLineColumnHeader; @@ -55,9 +60,9 @@ namespace ICSharpCode.CodeCoverage if (listView != null) { listView.Items.Clear(); } - if (textEditorControl != null) { - textEditorControl.FileName = null; - textEditorControl.Text = String.Empty; + if (textEditor != null) { + textEditorFileName = null; + textEditor.Text = String.Empty; } } @@ -150,15 +155,15 @@ namespace ICSharpCode.CodeCoverage // Add text editor if (showSourceCodePanel) { if (showVisitCountPanel) { - if (verticalSplitContainer.Panel2.Controls.Contains(textEditorControl)) { - verticalSplitContainer.Panel2.Controls.Remove(textEditorControl); + if (verticalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { + verticalSplitContainer.Panel2.Controls.Remove(textEditorHost); } - if (!horizontalSplitContainer.Panel2.Controls.Contains(textEditorControl)) { - horizontalSplitContainer.Panel2.Controls.Add(textEditorControl); + if (!horizontalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { + horizontalSplitContainer.Panel2.Controls.Add(textEditorHost); } } else { - if (!verticalSplitContainer.Panel2.Controls.Contains(textEditorControl)) { - verticalSplitContainer.Panel2.Controls.Add(textEditorControl); + if (!verticalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { + verticalSplitContainer.Panel2.Controls.Add(textEditorHost); } } } @@ -203,7 +208,7 @@ namespace ICSharpCode.CodeCoverage if (listView != null) { UpdateListView(node); } - if (textEditorControl != null) { + if (textEditor != null) { UpdateTextEditor(node); } } @@ -304,13 +309,13 @@ namespace ICSharpCode.CodeCoverage void OpenFile(string fileName, int line, int column) { - if (fileName != textEditorControl.FileName) { - textEditorControl.LoadFile(fileName, true, true); + if (fileName != textEditorFileName) { + textEditor.Load(fileName); } - textEditorControl.ActiveTextAreaControl.ScrollTo(int.MaxValue); - textEditorControl.ActiveTextAreaControl.Caret.Line = line - 1; - textEditorControl.ActiveTextAreaControl.ScrollToCaret(); - CodeCoverageService.ShowCodeCoverage(new TextEditorAdapter(textEditorControl), fileName); + textEditor.ScrollToEnd(); + textEditor.TextArea.Caret.Line = line - 1; + textEditor.ScrollToLine(line - 1); + CodeCoverageService.ShowCodeCoverage(new AvalonEditTextEditorAdapter(textEditor), fileName); } void CreateTreeView() @@ -467,8 +472,8 @@ namespace ICSharpCode.CodeCoverage horizontalSplitContainer.Panel1.Controls.Remove(listView); } - if (textEditorControl != null && horizontalSplitContainer.Panel2.Controls.Contains(textEditorControl)) { - horizontalSplitContainer.Panel2.Controls.Remove(textEditorControl); + if (textEditor != null && horizontalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { + horizontalSplitContainer.Panel2.Controls.Remove(textEditorHost); } if (verticalSplitContainer != null && verticalSplitContainer.Panel2.Controls.Contains(horizontalSplitContainer)) { @@ -481,41 +486,43 @@ namespace ICSharpCode.CodeCoverage void CreateTextEditor() { - if (textEditorControl != null) { + if (textEditorHost != null) { return; } - textEditorControl = new TextEditorControl(); - textEditorControl.Dock = DockStyle.Fill; - textEditorControl.Document.ReadOnly = true; - textEditorControl.TextEditorProperties = SharpDevelopTextEditorProperties.Instance; - textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick += TextEditorControlDoubleClick; + textEditor = AvalonEditTextEditorAdapter.CreateAvalonEditInstance(); + textEditor.IsReadOnly = true; + textEditor.MouseDoubleClick += TextEditorDoubleClick; + + textEditorHost = new ElementHost(); + textEditorHost.Dock = DockStyle.Fill; + textEditorHost.Child = textEditor; } void DisposeTextEditor() { - if (textEditorControl == null) { + if (textEditorHost == null) { return; } - if (verticalSplitContainer.Panel2.Controls.Contains(textEditorControl)) { - verticalSplitContainer.Panel2.Controls.Remove(textEditorControl); + if (verticalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { + verticalSplitContainer.Panel2.Controls.Remove(textEditorHost); } - if (horizontalSplitContainer != null && horizontalSplitContainer.Panel2.Controls.Contains(textEditorControl)) { - horizontalSplitContainer.Panel2.Controls.Remove(textEditorControl); + if (horizontalSplitContainer != null && horizontalSplitContainer.Panel2.Controls.Contains(textEditorHost)) { + horizontalSplitContainer.Panel2.Controls.Remove(textEditorHost); } - textEditorControl.ActiveTextAreaControl.TextArea.DoubleClick -= TextEditorControlDoubleClick; - textEditorControl.Dispose(); - textEditorControl = null; + textEditor.MouseDoubleClick -= TextEditorDoubleClick; + textEditorHost.Dispose(); + textEditorHost = null; } - void TextEditorControlDoubleClick(object sender, EventArgs e) + void TextEditorDoubleClick(object sender, EventArgs e) { - string fileName = textEditorControl.FileName; + string fileName = textEditorFileName; if (fileName != null) { - Caret caret = textEditorControl.ActiveTextAreaControl.Caret; + Caret caret = textEditor.TextArea.Caret; FileService.JumpToFilePosition(fileName, caret.Line + 1, caret.Column + 1); } } diff --git a/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs b/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs index 28b6a5d19d..cd5629e8de 100644 --- a/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs +++ b/src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs @@ -34,9 +34,9 @@ namespace ICSharpCode.CodeCoverage runner.OutputLineReceived += OutputLineReceived; } - protected override void RunTests(UnitTestApplicationStartHelper helper) + protected override void RunTests(NUnitConsoleApplication app) { - SetPartCoverRunnerProperties(helper); + SetPartCoverRunnerProperties(app); RunPartCover(); } @@ -62,7 +62,7 @@ namespace ICSharpCode.CodeCoverage protected override void OnAfterRunTests() { if (!TaskService.HasCriticalErrors(false)) { - ShowPad(WorkbenchSingleton.Workbench.GetPad(typeof(CodeCoveragePad))); + ShowPad(Context.Workbench.GetPad(typeof(CodeCoveragePad))); } } @@ -78,10 +78,10 @@ namespace ICSharpCode.CodeCoverage } } - void SetPartCoverRunnerProperties(UnitTestApplicationStartHelper helper) + void SetPartCoverRunnerProperties(NUnitConsoleApplication app) { - string partCoverOutputDirectory = GetPartCoverOutputDirectory(helper.Project); - PartCoverSettings settings = GetPartCoverSettings(helper.Project); + string partCoverOutputDirectory = GetPartCoverOutputDirectory(app.Project); + PartCoverSettings settings = GetPartCoverSettings(app.Project); // By default get the code coverage for everything if // no include or exclude regular expressions have been @@ -94,9 +94,9 @@ namespace ICSharpCode.CodeCoverage } runner.PartCoverFileName = GetPartCoverFileName(); - runner.Target = helper.UnitTestApplication; - runner.TargetArguments = helper.GetArguments(); - runner.TargetWorkingDirectory = Path.GetDirectoryName(helper.Assemblies[0]); + runner.Target = app.FileName; + runner.TargetArguments = app.GetArguments(); + runner.TargetWorkingDirectory = Path.GetDirectoryName(app.Assemblies[0]); runner.Output = Path.Combine(partCoverOutputDirectory, "Coverage.Xml"); AddStringsToCollection(settings.Include, runner.Include); AddStringsToCollection(settings.Exclude, runner.Exclude); @@ -128,7 +128,7 @@ namespace ICSharpCode.CodeCoverage void PartCoverExited(object sender, PartCoverExitEventArgs e) { DisplayCoverageResults(runner.Output); - WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished); + WorkbenchSingleton.SafeThreadAsyncCall(TestRunCompleted); } void OutputLineReceived(object sender, LineReceivedEventArgs e) diff --git a/src/AddIns/Analysis/CodeCoverage/Test/CodeCoverage.Tests.csproj b/src/AddIns/Analysis/CodeCoverage/Test/CodeCoverage.Tests.csproj index 0349c78262..7f30c5e6fa 100644 --- a/src/AddIns/Analysis/CodeCoverage/Test/CodeCoverage.Tests.csproj +++ b/src/AddIns/Analysis/CodeCoverage/Test/CodeCoverage.Tests.csproj @@ -68,7 +68,6 @@ - @@ -112,10 +111,6 @@ {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} ICSharpCode.Core - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - {08CE9972-283B-44F4-82FA-966F7DFA6B7A} CodeCoverage diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.addin b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.addin new file mode 100644 index 0000000000..d05b1f1ce6 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.addin @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj new file mode 100644 index 0000000000..45fd0224a8 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.csproj @@ -0,0 +1,188 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3} + WinExe + Properties + ICSharpCode.CodeQualityAnalysis + CodeQualityAnalysis + v4.0 + + + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + ..\..\..\..\AddIns\AddIns\Misc\CodeQualityAnalysis\ + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\Libraries\GraphSharp\GraphSharp.dll + + + ..\..\..\Libraries\GraphSharp\GraphSharp.Contracts.dll + + + ..\..\..\Libraries\GraphSharp\GraphSharp.Controls.dll + + + ..\..\..\Libraries\GraphSharp\Microsoft.Contracts.dll + + + ..\..\..\Libraries\Mono.Cecil\Mono.Cecil.dll + + + ..\..\..\Libraries\GraphSharp\QuickGraph.dll + + + + + + + + + + 4.0 + + + + + + ..\..\..\Libraries\GraphSharp\WPFExtensions.dll + + + + + MSBuild:Compile + Designer + + + + + + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + False + Microsoft .NET Framework 4 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + + + {2748AD25-9C63-4E12-877B-4DCE96FBED54} + ICSharpCode.SharpDevelop + False + + + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} + ICSharpCode.Core + False + + + + + Always + + + + + \ No newline at end of file diff --git a/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln new file mode 100644 index 0000000000..0cbc948790 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/CodeQualityAnalysis.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeQualityAnalysis", "CodeQualityAnalysis.csproj", "{76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\..\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop", "..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj", "{2748AD25-9C63-4E12-877B-4DCE96FBED54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|x86.ActiveCfg = Debug|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Debug|x86.Build.0 = Debug|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|Any CPU.Build.0 = Release|Any CPU + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|x86.ActiveCfg = Release|x86 + {76DD1CC0-0D86-44A1-9BD6-D91F79807BC3}.Release|x86.Build.0 = Release|x86 + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|x86.ActiveCfg = Debug|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU + {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|x86.ActiveCfg = Release|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Debug|x86.ActiveCfg = Debug|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|Any CPU.Build.0 = Release|Any CPU + {2748AD25-9C63-4E12-877B-4DCE96FBED54}.Release|x86.ActiveCfg = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/AddIns/Analysis/CodeQuality/Properties/AssemblyInfo.cs b/src/AddIns/Analysis/CodeQuality/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..fc1d448e19 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Code-Quality-Analysis")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Code-Quality-Analysis")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Libraries/AvalonDock/Properties/Resources.Designer.cs b/src/AddIns/Analysis/CodeQuality/Properties/Resources.Designer.cs similarity index 89% rename from src/Libraries/AvalonDock/Properties/Resources.Designer.cs rename to src/AddIns/Analysis/CodeQuality/Properties/Resources.Designer.cs index 6204034140..98e89b2261 100644 --- a/src/Libraries/AvalonDock/Properties/Resources.Designer.cs +++ b/src/AddIns/Analysis/CodeQuality/Properties/Resources.Designer.cs @@ -1,14 +1,14 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace AvalonDock.Properties { +namespace ICSharpCode.CodeQualityAnalysis.Properties { using System; @@ -19,7 +19,7 @@ namespace AvalonDock.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { @@ -39,7 +39,7 @@ namespace AvalonDock.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AvalonDock.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ICSharpCode.CodeQualityAnalysis.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/Libraries/AvalonDock/Properties/Resources.resx b/src/AddIns/Analysis/CodeQuality/Properties/Resources.resx similarity index 96% rename from src/Libraries/AvalonDock/Properties/Resources.resx rename to src/AddIns/Analysis/CodeQuality/Properties/Resources.resx index 3e18af958a..af7dbebbac 100644 --- a/src/Libraries/AvalonDock/Properties/Resources.resx +++ b/src/AddIns/Analysis/CodeQuality/Properties/Resources.resx @@ -109,9 +109,9 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/src/Libraries/AvalonDock/Properties/Settings.Designer.cs b/src/AddIns/Analysis/CodeQuality/Properties/Settings.Designer.cs similarity index 89% rename from src/Libraries/AvalonDock/Properties/Settings.Designer.cs rename to src/AddIns/Analysis/CodeQuality/Properties/Settings.Designer.cs index f67dbf13f4..675a5bb70c 100644 --- a/src/Libraries/AvalonDock/Properties/Settings.Designer.cs +++ b/src/AddIns/Analysis/CodeQuality/Properties/Settings.Designer.cs @@ -1,18 +1,18 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.1433 +// Runtime Version:4.0.30319.1 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace AvalonDock.Properties { +namespace ICSharpCode.CodeQualityAnalysis.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/src/Libraries/AvalonDock/Properties/Settings.settings b/src/AddIns/Analysis/CodeQuality/Properties/Settings.settings similarity index 70% rename from src/Libraries/AvalonDock/Properties/Settings.settings rename to src/AddIns/Analysis/CodeQuality/Properties/Settings.settings index 4024694778..033d7a5e9e 100644 --- a/src/Libraries/AvalonDock/Properties/Settings.settings +++ b/src/AddIns/Analysis/CodeQuality/Properties/Settings.settings @@ -1,4 +1,4 @@ - + diff --git a/src/AddIns/Analysis/CodeQuality/Src/App.xaml b/src/AddIns/Analysis/CodeQuality/Src/App.xaml new file mode 100644 index 0000000000..31fb3e1ae0 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/App.xaml @@ -0,0 +1,8 @@ + + + + + diff --git a/src/AddIns/Analysis/CodeQuality/Src/App.xaml.cs b/src/AddIns/Analysis/CodeQuality/Src/App.xaml.cs new file mode 100644 index 0000000000..5432ff6c0f --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/App.xaml.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Windows; + +namespace ICSharpCode.CodeQualityAnalysis +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/DependencyGraphCommand.cs b/src/AddIns/Analysis/CodeQuality/Src/DependencyGraphCommand.cs new file mode 100644 index 0000000000..81398566da --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/DependencyGraphCommand.cs @@ -0,0 +1,14 @@ +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public class DependencyGraphCommand : AbstractMenuCommand + { + public override void Run() + { + var window = new MainWindow(); + window.Show(); + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/Field.cs b/src/AddIns/Analysis/CodeQuality/Src/Field.cs new file mode 100644 index 0000000000..1305024ec7 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/Field.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using QuickGraph; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public class Field : IDependency + { + /// + /// Name of field + /// + public string Name { get; set; } + + /// + /// Type of field + /// + public Type Type { get; set; } + + public BidirectionalGraph> BuildDependencyGraph() + { + return null; + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/IDependency.cs b/src/AddIns/Analysis/CodeQuality/Src/IDependency.cs new file mode 100644 index 0000000000..97836ad15e --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/IDependency.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using QuickGraph; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public interface IDependency + { + string Name { set; get; } + BidirectionalGraph> BuildDependencyGraph(); + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml new file mode 100644 index 0000000000..6ff817cc0a --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs new file mode 100644 index 0000000000..cc9fbcab09 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/MainWindow.xaml.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Microsoft.Win32; +using Mono.Cecil; +using Mono.Cecil.Cil; +using QuickGraph; +using QuickGraph.Collections; + +namespace ICSharpCode.CodeQualityAnalysis +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + private MetricsReader _metricsReader; + + public MainWindow() + { + InitializeComponent(); + } + + private void btnOpenAssembly_Click(object sender, RoutedEventArgs e) + { + var fileDialog = new OpenFileDialog + { + Filter = "Component Files (*.dll, *.exe)|*.dll;*.exe" + }; + + fileDialog.ShowDialog(); + + if (String.IsNullOrEmpty(fileDialog.FileName)) + return; + + definitionTree.Items.Clear(); + + _metricsReader = new MetricsReader(fileDialog.FileName); + + FillTree(); + } + + /// + /// Fill tree with module, types and methods and TODO: fields + /// + private void FillTree() + { + var itemModule = new MetricTreeViewItem() { Header = _metricsReader.MainModule.Name, Dependency = _metricsReader.MainModule }; + definitionTree.Items.Add(itemModule); + + foreach (var ns in _metricsReader.MainModule.Namespaces) + { + var nsType = new MetricTreeViewItem() { Header = ns.Name, Dependency = ns }; + itemModule.Items.Add(nsType); + + foreach (var type in ns.Types) + { + var itemType = new MetricTreeViewItem() { Header = type.Name, Dependency = type }; + nsType.Items.Add(itemType); + + foreach (var method in type.Methods) + { + var itemMethod = new MetricTreeViewItem() { Header = method.Name, Dependency = method }; + itemType.Items.Add(itemMethod); + } + + foreach (var field in type.Fields) + { + var itemField = new MetricTreeViewItem() { Header = field.Name, Dependency = field }; + itemType.Items.Add(itemField); + } + } + } + } + + private void definitionTree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs e) + { + var item = definitionTree.SelectedItem as MetricTreeViewItem; + + if (item != null) + { + // would be better inherit from TreeViewItem and add reference into it + // will do it later or will use another tree maybe tree from SharpDevelop + string name = item.Header.ToString(); + txbTypeInfo.Text = "Infobox: \n" + name; + /*var type = (from n in this._metricsReader.MainModule.Namespaces + from t in n.Types + where t.Name == name + select t).SingleOrDefault();*/ + + var graph = item.Dependency.BuildDependencyGraph(); + if (graph != null && graph.VertexCount > 0) + { + graphLayout.Graph = graph; + } + } + + } + + private class MetricTreeViewItem : TreeViewItem + { + public IDependency Dependency { get; set; } + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/Method.cs b/src/AddIns/Analysis/CodeQuality/Src/Method.cs new file mode 100644 index 0000000000..006c4db81f --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/Method.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using QuickGraph; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public class Method : IDependency + { + /// + /// Types which are used in body of method + /// + public ISet TypeUses { get; set; } + + /// + /// Methods which are called in body of method + /// + public ISet MethodUses { get; set; } + + /// + /// Fields which are accesed in body of method + /// + public ISet FieldUses { get; set; } + + /// + /// A name of method + /// + public string Name { get; set; } + + /// + /// A return type of method + /// + public Type Type { get; set; } + + public Method() + { + TypeUses = new HashSet(); + MethodUses = new HashSet(); + FieldUses = new HashSet(); + } + + public BidirectionalGraph> BuildDependencyGraph() + { + return null; + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs b/src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs new file mode 100644 index 0000000000..82c0e3d5c0 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/MetricsReader.cs @@ -0,0 +1,361 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Mono.Cecil; +using Mono.Cecil.Cil; +using Mono.Collections.Generic; + +namespace ICSharpCode.CodeQualityAnalysis +{ + /// + /// Reads neccesery information with Mono.Cecil to calculate code metrics + /// + public class MetricsReader + { + public Module MainModule { get; private set; } + + public MetricsReader(string file) + { + this.ReadAssembly(file); + } + + /// + /// Opens file as assembly and starts reading MainModule + /// + /// + private void ReadAssembly(string file) + { + var assembly = AssemblyDefinition.ReadAssembly(file); + ReadModule(assembly.MainModule); + } + + /// + /// Reads main module from assembly + /// + /// + private void ReadModule(ModuleDefinition moduleDefinition) + { + this.MainModule = new Module() + { + Name = moduleDefinition.Name + }; + + ReadTypes(MainModule, moduleDefinition.Types); + } + + /// + /// Reads types from module + /// + /// + /// + private void ReadTypes(Module module, Collection types) + { + // first add all types, because i will need find depend types + + foreach (TypeDefinition typeDefinition in types) + { + if (typeDefinition.Name != "") + { + var type = new Type() + { + FullName = FormatTypeName(typeDefinition), + Name = FormatTypeName(typeDefinition) + }; + + // try find namespace + var nsName = GetNamespaceName(typeDefinition); + + var ns = (from n in module.Namespaces + where n.Name == nsName + select n).SingleOrDefault(); + + if (ns == null) + { + ns = new Namespace() + { + Name = nsName, + Module = module + }; + + module.Namespaces.Add(ns); + } + + type.Namespace = ns; + ns.Types.Add(type); + } + } + + foreach (TypeDefinition typeDefinition in types) + { + if (typeDefinition.Name != "") + { + var type = + (from n in module.Namespaces + from t in n.Types + where (t.Name == FormatTypeName(typeDefinition)) + select t).SingleOrDefault(); + + + if (typeDefinition.HasFields) + ReadFields(type, typeDefinition.Fields); + + /*if (typeDefinition.HasEvents) + ReadEvents(type, typeDefinition.Events);*/ + + if (typeDefinition.HasMethods) + ReadMethods(type, typeDefinition.Methods); + + /*if (typeDefinition.HasConstructors) + ReadConstructors(type, typeDefinition.Constructors);*/ + } + } + + } + + private void ReadEvents(Type type, Collection events) + { + throw new NotImplementedException(); + } + + /// + /// Reads fields and add them to field list for type + /// + /// + /// + private void ReadFields(Type type, Collection fields) + { + foreach (FieldDefinition fieldDefinition in fields) + { + var field = new Field() + { + Name = fieldDefinition.Name + }; + + type.Fields.Add(field); + + var declaringType = + (from n in type.Namespace.Module.Namespaces + from t in n.Types + where t.Name == field.Name + select t).SingleOrDefault(); + + field.Type = declaringType; + } + } + + /// + /// Extracts methods and add them to method list for type + /// + /// + /// + private void ReadMethods(Type type, Collection methods) + { + foreach (MethodDefinition methodDefinition in methods) + { + var method = new Method + { + Name = FormatMethodName(methodDefinition), + Type = type + }; + + type.Methods.Add(method); + } + + foreach (MethodDefinition methodDefinition in methods) + { + var method = (from m in type.Methods + where m.Name == FormatMethodName(methodDefinition) + select m).SingleOrDefault(); + + if (methodDefinition.Body != null) + { + ReadInstructions(method, methodDefinition, methodDefinition.Body.Instructions); + } + } + } + + /// + /// Reads constructors and add them to method list for type + /// + /// + /// + private void ReadConstructors(Type type, Collection constructors) + { + foreach (MethodDefinition constructor in constructors) + { + var method = new Method + { + Name = FormatMethodName(constructor), + Type = type + }; + + type.Methods.Add(method); + } + + foreach (MethodDefinition constructor in constructors) + { + var method = (from m in type.Methods + where m.Name == FormatMethodName(constructor) + select m).SingleOrDefault(); + + if (constructor.Body != null) + { + ReadInstructions(method, constructor, constructor.Body.Instructions); + } + } + } + + /// + /// Reads method calls by extracting instrunctions + /// + /// + /// + /// + public void ReadInstructions(Method method, MethodDefinition methodDefinition, + Collection instructions) + { + foreach (Instruction instruction in instructions) + { + var instr = ReadInstruction(instruction); + + if (instr is MethodDefinition) + { + var md = instr as MethodDefinition; + var type = (from n in method.Type.Namespace.Module.Namespaces + from t in n.Types + where t.Name == FormatTypeName(md.DeclaringType) && + n.Name == t.Namespace.Name + select t).SingleOrDefault(); + + method.TypeUses.Add(type); + + var findTargetMethod = (from m in type.Methods + where m.Name == FormatMethodName(md) + select m).SingleOrDefault(); + + if (findTargetMethod != null && type == method.Type) + method.MethodUses.Add(findTargetMethod); + } + + if (instr is FieldDefinition) + { + var fd = instr as FieldDefinition; + var field = (from f in method.Type.Fields + where f.Name == fd.Name + select f).SingleOrDefault(); + + if (field != null) + method.FieldUses.Add(field); + } + } + } + + /// + /// Reads instruction operand by recursive calling until non-instruction + /// operand is found + /// + /// + /// + public object ReadInstruction(Instruction instruction) + { + if (instruction.Operand == null) + return null; + + var nextInstruction = instruction.Operand as Instruction; + + if (nextInstruction != null) + return ReadInstruction(nextInstruction); + else + return instruction.Operand; + } + + /// + /// Formats method name by adding parameters to it. If there are not any parameters + /// only empty brackers will be added. + /// + /// + /// + public string FormatMethodName(MethodDefinition methodDefinition) + { + if (methodDefinition.HasParameters) + { + var builder = new StringBuilder(); + var enumerator = methodDefinition.Parameters.GetEnumerator(); + bool hasNext = enumerator.MoveNext(); + while (hasNext) + { + builder.Append(((ParameterDefinition) enumerator.Current).ParameterType.FullName); + hasNext = enumerator.MoveNext(); + if (hasNext) + builder.Append(", "); + } + + return methodDefinition.Name + "(" + builder.ToString() + ")"; + } + else + { + return methodDefinition.Name + "()"; + } + } + + /// + /// Formats a specific type name. If type is generic. Brackets <> will be added with proper names of parameters. + /// + /// + /// + public string FormatTypeName(TypeDefinition typeDefinition) + { + if (typeDefinition.IsNested && typeDefinition.DeclaringType != null) + { + return FormatTypeName(typeDefinition.DeclaringType) + "+" + typeDefinition.Name; + } + + if (typeDefinition.HasGenericParameters) + { + var builder = new StringBuilder(); + var enumerator = typeDefinition.GenericParameters.GetEnumerator(); + bool hasNext = enumerator.MoveNext(); + while (hasNext) + { + builder.Append(((GenericParameter)enumerator.Current).Name); + hasNext = enumerator.MoveNext(); + if (hasNext) + builder.Append(","); + } + + return StripGenericName(typeDefinition.Name) + "<" + builder.ToString() + ">"; + } + + return typeDefinition.Name; + } + + /// + /// Removes a number of generics parameters. Eg. `3 will be removed from end of name. + /// + /// + /// + private string StripGenericName(string name) + { + return name.IndexOf('`') != -1 ? name.Remove(name.IndexOf('`')) : name; + } + + /// + /// Gets namespace name. If type is nested it looks recursively to parent type until finds his namespace. + /// + /// + /// + private string GetNamespaceName(TypeDefinition type) + { + if (type.IsNested && type.DeclaringType != null) + return GetNamespaceName(type.DeclaringType); + else + { + if (!String.IsNullOrEmpty(type.Namespace)) + return type.Namespace; + else + return "-"; + } + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/Module.cs b/src/AddIns/Analysis/CodeQuality/Src/Module.cs new file mode 100644 index 0000000000..2e7b203960 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/Module.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using QuickGraph; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public class Module : IDependency + { + /// + /// Namespaces within module + /// + public ISet Namespaces { get; set; } + + /// + /// Name of module + /// + public string Name { get; set; } + + public Module() + { + Namespaces = new HashSet(); + } + + public BidirectionalGraph> BuildDependencyGraph() + { + return null; + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/Namespace.cs b/src/AddIns/Analysis/CodeQuality/Src/Namespace.cs new file mode 100644 index 0000000000..6dd57f7214 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/Namespace.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using QuickGraph; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public class Namespace : IDependency + { + /// + /// Types within namespace + /// + public ISet Types { get; set; } + + /// + /// Name of namespace + /// + public string Name { get; set; } + + /// + /// Module where is namespace located + /// + public Module Module { get; set; } + + public Namespace() + { + Types = new HashSet(); + } + + public BidirectionalGraph> BuildDependencyGraph() + { + var g = new BidirectionalGraph>(); + + foreach (var type in Types) + { + g.AddVertex(type.Name); + } + + foreach (var type in Types) + { + var types = type.GetUses(); + + foreach (var dependType in types) + { + if (dependType != type && dependType.Namespace == type.Namespace) + g.AddEdge(new Edge(type.Name, dependType.Name)); + } + } + + return g; + } + } +} diff --git a/src/AddIns/Analysis/CodeQuality/Src/Type.cs b/src/AddIns/Analysis/CodeQuality/Src/Type.cs new file mode 100644 index 0000000000..326735a585 --- /dev/null +++ b/src/AddIns/Analysis/CodeQuality/Src/Type.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using QuickGraph; + +namespace ICSharpCode.CodeQualityAnalysis +{ + public class Type : IDependency + { + /// + /// Nested types like inner classes, interfaces and so on. + /// + public ISet InnerTypes { get; set; } + + /// + /// Methods within type + /// + public ISet Methods { get; set; } + + /// + /// Fields within type + /// + public ISet Fields { get; set; } + + /// + /// Name of type with a name of namespace. + /// + public string FullName { get; set; } + + /// + /// Name of type + /// + public string Name { get; set; } + + /// + /// Namespace where type is located + /// + public Namespace Namespace { get; set; } + + public Type() + { + Methods = new HashSet(); + Fields = new HashSet(); + } + + /// + /// Returns all types which are used in this type + /// + /// A set of types + public ISet GetUses() + { + var set = new HashSet(); + + foreach (var method in Methods) + { + set.UnionWith(method.TypeUses); + } + + foreach (var field in Fields) + { + if (field.Type != null) // if it is null so it is type from outside of this assembly + set.Add(field.Type); // TODO: find solution to handle them + } + + return set; + } + + public BidirectionalGraph> BuildDependencyGraph() + { + var g = new BidirectionalGraph>(); + + foreach (var method in Methods) + { + g.AddVertex(method.Name); + } + + foreach (var field in Fields) + { + g.AddVertex(field.Name); + } + + foreach (var method in Methods) + { + foreach (var methodUse in method.MethodUses) + { + g.AddEdge(new Edge(method.Name, methodUse.Name)); + } + + foreach (var fieldUse in method.FieldUses) + { + g.AddEdge(new Edge(method.Name, fieldUse.Name)); + } + } + + return g; + } + } +} diff --git a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj index 8cda72ef01..de5de3bc4e 100644 --- a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj +++ b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Profiler.AddIn.csproj @@ -89,6 +89,7 @@ + ComparisonView.xaml diff --git a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs index b051eca516..b68b166f9f 100644 --- a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs +++ b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/Commands/RunTestWithProfilerCommand.cs @@ -5,82 +5,16 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.Gui; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using ICSharpCode.Core; -using ICSharpCode.Profiler.AddIn; -using ICSharpCode.Profiler.Controller.Data; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; namespace ICSharpCode.Profiler.AddIn.Commands { public class RunTestWithProfilerCommand : AbstractRunTestCommand { - ProfilerRunner runner; - - protected override void RunTests(UnitTestApplicationStartHelper helper) + protected override ITestRunner CreateTestRunner(IProject project) { - TestRunnerCategory.AppendLine(helper.GetCommandLine()); - - ProcessStartInfo startInfo = new ProcessStartInfo(helper.UnitTestApplication); - - string path = helper.Project.GetSessionFileName(); - - startInfo.Arguments = helper.GetArguments(); - startInfo.WorkingDirectory = UnitTestApplicationStartHelper.UnitTestApplicationDirectory; - LoggingService.Info("starting profiler..."); - - runner = new ProfilerRunner(startInfo, true, new UnitTestWriter(new ProfilingDataSQLiteWriter(path), GetUnitTestNames(helper).ToArray())); - - runner.RunFinished += delegate { - WorkbenchSingleton.SafeThreadCall(() => FileService.OpenFile(path)); - AfterFinish(helper, path); - }; - - runner.Run(); - } - - IEnumerable GetUnitTestNames(UnitTestApplicationStartHelper helper) - { - IProjectContent content = ParserService.GetProjectContent(helper.Project); - - if (helper.Fixture == null) { - var testClasses = content.Classes - .Where(c => c.Attributes.Any(a => a.AttributeType.FullyQualifiedName == "NUnit.Framework.TestFixtureAttribute")); - return testClasses - .SelectMany(c2 => c2.Methods) - .Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute")) - .Select(m2 => m2.FullyQualifiedName); - } - - if (helper.Test == null) { - return content.Classes - .Where(c => c.FullyQualifiedName == helper.Fixture).First().Methods - .Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute")) - .Select(m2 => m2.FullyQualifiedName); - } - - return new[] { helper.Fixture + "." + helper.Test }; - } - - void AfterFinish(UnitTestApplicationStartHelper helper, string path) - { - helper.Project.AddSessionToProject(path); - WorkbenchSingleton.SafeThreadAsyncCall(TestsFinished); - LoggingService.Info("shutting profiler down..."); - } - - protected override void OnStop() - { - if (this.runner != null && this.runner.Profiler.IsRunning) { - LoggingService.Info("stopping profiler..."); - runner.Stop(); - } + return new ProfilerTestRunner(); } } } diff --git a/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerTestRunner.cs b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerTestRunner.cs new file mode 100644 index 0000000000..f7a622836d --- /dev/null +++ b/src/AddIns/Analysis/Profiler/Frontend/AddIn/Src/ProfilerTestRunner.cs @@ -0,0 +1,115 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using ICSharpCode.Core; +using ICSharpCode.Profiler.AddIn; +using ICSharpCode.Profiler.Controller.Data; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.Profiler.AddIn +{ + public class ProfilerTestRunner : TestRunnerBase + { + ProfilerRunner runner; + UnitTestingOptions options = new UnitTestingOptions(); + TestResultsMonitor testResultsMonitor; + + public ProfilerTestRunner() + { + } + + public override void Start(SelectedTests selectedTests) + { + ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests); + Start(startInfo, selectedTests); + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options); + testResultsMonitor = new TestResultsMonitor(); + app.Results = testResultsMonitor.FileName; + return app.GetProcessStartInfo(); + } + + void Start(ProcessStartInfo startInfo, SelectedTests selectedTests) + { + LogCommandLine(startInfo); + + string path = selectedTests.Project.GetSessionFileName(); + + LoggingService.Info("starting profiler..."); + + runner = new ProfilerRunner(startInfo, true, new UnitTestWriter(new ProfilingDataSQLiteWriter(path), GetUnitTestNames(selectedTests).ToArray())); + + runner.RunFinished += delegate { + WorkbenchSingleton.SafeThreadCall(() => FileService.OpenFile(path)); + AfterFinish(selectedTests, path); + }; + + testResultsMonitor.TestFinished += OnTestFinished; + testResultsMonitor.Start(); + runner.Run(); + } + + IEnumerable GetUnitTestNames(SelectedTests selectedTests) + { + IProjectContent content = ParserService.GetProjectContent(selectedTests.Project); + + if (selectedTests.Class == null) { + var testClasses = content.Classes + .Where(c => c.Attributes.Any(a => a.AttributeType.FullyQualifiedName == "NUnit.Framework.TestFixtureAttribute")); + return testClasses + .SelectMany(c2 => c2.Methods) + .Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute")) + .Select(m2 => m2.FullyQualifiedName); + } + + if (selectedTests.Method == null) { + return content.Classes + .Where(c => c.FullyQualifiedName == selectedTests.Class.DotNetName).First().Methods + .Where(m => m.Attributes.Any(a2 => a2.AttributeType.FullyQualifiedName == "NUnit.Framework.TestAttribute")) + .Select(m2 => m2.FullyQualifiedName); + } + + return new[] { selectedTests.Class.DotNetName + "." + selectedTests.Method.Name }; + } + + void AfterFinish(SelectedTests selectedTests, string path) + { + selectedTests.Project.AddSessionToProject(path); + OnAllTestsFinished(this, new EventArgs()); + LoggingService.Info("shutting profiler down..."); + } + + public override void Stop() + { + if (this.runner != null && this.runner.Profiler.IsRunning) { + LoggingService.Info("stopping profiler..."); + runner.Stop(); + } + + if (testResultsMonitor != null) { + testResultsMonitor.Stop(); + testResultsMonitor.Read(); + testResultsMonitor = null; + } + } + + public override void Dispose() + { + Stop(); + } + } +} diff --git a/src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.csproj b/src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.csproj index 44a6363fed..d01fdcb70a 100644 --- a/src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.csproj +++ b/src/AddIns/Analysis/SourceAnalysis/SourceAnalysis.csproj @@ -1,4 +1,5 @@ - + + Library MattEverson.SourceAnalysis @@ -72,11 +73,6 @@ - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} NRefactory diff --git a/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs b/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs new file mode 100644 index 0000000000..5cba431e82 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/AbstractRunTestCommands.cs @@ -0,0 +1,332 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public abstract class AbstractRunTestCommand : AbstractMenuCommand + { + static AbstractRunTestCommand runningTestCommand; + IUnitTestsPad unitTestsPad; + SelectedTests selectedTests; + IRunTestCommandContext context; + ITestRunner testRunner; + + public AbstractRunTestCommand() + : this(new RunTestCommandContext()) + { + } + + public AbstractRunTestCommand(IRunTestCommandContext context) + { + this.context = context; + } + + protected IRunTestCommandContext Context { + get { return context; } + } + + /// + /// Gets the running test command. + /// + public static AbstractRunTestCommand RunningTestCommand { + get { return runningTestCommand; } + set { runningTestCommand = value; } + } + + /// + /// Gets whether a test is currently running. + /// + public static bool IsRunningTest { + get { return runningTestCommand != null; } + } + + public override void Run() + { + GetUnitTestsPad(context.OpenUnitTestsPad); + + selectedTests = new SelectedTests(Owner, this.unitTestsPad.GetProjects()); + if (selectedTests.HasProjects) { + runningTestCommand = this; + BeforeRun(); + RunTests(); + } + } + + void GetUnitTestsPad(IUnitTestsPad unitTestsPad) + { + if (unitTestsPad != null) { + this.unitTestsPad = unitTestsPad; + } else { + this.unitTestsPad = new EmptyUnitTestsPad(); + } + } + + /// + /// Sets the initial workbench state before starting + /// a test run. + /// + void BeforeRun() + { + ClearTasks(); + ClearUnitTestCategoryText(); + + ShowUnitTestsPad(); + ShowOutputPad(); + + UpdateUnitTestsPadToolbar(); + ResetAllTestResultsInUnitTestsPad(); + + OnBeforeRunTests(); + } + + void RunTests() + { + if (IsBuildNeededBeforeTestRun()) { + BuildProjectBeforeRunningTests(selectedTests); + } else { + context.SaveAllFilesCommand.SaveAllFiles(); + RunTests(selectedTests); + } + } + + bool IsBuildNeededBeforeTestRun() + { + return context.RegisteredTestFrameworks.IsBuildNeededBeforeTestRunForProject(selectedTests.Project); + } + + void ClearTasks() + { + context.TaskService.BuildMessageViewCategory.ClearText(); + context.TaskService.InUpdate = true; + context.TaskService.ClearExceptCommentTasks(); + context.TaskService.InUpdate = false; + } + + void ClearUnitTestCategoryText() + { + context.UnitTestCategory.ClearText(); + } + + void ShowUnitTestsPad() + { + unitTestsPad.BringToFront(); + } + + void UpdateUnitTestsPadToolbar() + { + unitTestsPad.UpdateToolbar(); + } + + /// + /// Called before all tests are run. If multiple projects are + /// to be tested this is called only once. + /// + protected virtual void OnBeforeRunTests() + { + } + + /// + /// Runs the tests after building the project under test. + /// + void BuildProjectBeforeRunningTests(SelectedTests selectedTests) + { + BuildProjectBeforeTestRun build = CreateBuildProjectBeforeTestRun(selectedTests); + build.BuildComplete += delegate { + OnBuildComplete(build.LastBuildResults, selectedTests); + }; + build.Run(); + } + + BuildProjectBeforeTestRun CreateBuildProjectBeforeTestRun(SelectedTests selectedTests) + { + return context.BuildProjectFactory.CreateBuildProjectBeforeTestRun(selectedTests.Project); + } + + /// + /// Stops running the tests. + /// + public void Stop() + { + StopActiveTestRunner(); + + runningTestCommand = null; + UpdateUnitTestsPadToolbar(); + + OnStop(); + } + + void StopActiveTestRunner() + { + if (testRunner != null) { + testRunner.Stop(); + testRunner.Dispose(); + testRunner = null; + } + } + + /// + /// Called after all tests have been run even if there have + /// been errors. If multiple projects are to be tested this is called only once. + /// + protected virtual void OnAfterRunTests() + { + } + + protected virtual void RunTests(NUnitConsoleApplication helper) + { + } + + /// + /// Called by derived classes when a single test run + /// is finished. + /// + protected void TestRunCompleted() + { + StopActiveTestRunner(); + selectedTests.RemoveFirstProject(); + if (selectedTests.HasProjects) { + RunTests(); + } else { + runningTestCommand = null; + UpdateUnitTestsPadToolbar(); + ShowErrorList(); + OnAfterRunTests(); + } + } + + void TestFinished(object source, TestFinishedEventArgs e) + { + context.Workbench.SafeThreadAsyncCall(ShowResult, e.Result); + } + + protected void ShowResult(TestResult result) + { + if (IsTestResultFailureOrIsIgnored(result)) { + AddTaskForTestResult(result); + } + UpdateTestResult(result); + } + + bool IsTestResultFailureOrIsIgnored(TestResult result) + { + return result.IsFailure || result.IsIgnored; + } + + void AddTaskForTestResult(TestResult testResult) + { + TestProject project = GetTestProjectForProject(selectedTests.Project); + Task task = TestResultTask.Create(testResult, project); + context.TaskService.Add(task); + } + + /// + /// Called when the test run should be stopped. + /// + protected virtual void OnStop() + { + } + + void ShowOutputPad() + { + ShowPad(context.Workbench.GetPad(typeof(CompilerMessageView))); + } + + protected void ShowPad(PadDescriptor padDescriptor) + { + context.Workbench.SafeThreadAsyncCall(padDescriptor.BringPadToFront); + } + + void ShowErrorList() + { + if (HasErrorsThatShouldBeDisplayed()) { + ShowPad(context.Workbench.GetPad(typeof(ErrorListPad))); + } + } + + bool HasErrorsThatShouldBeDisplayed() + { + return context.TaskService.SomethingWentWrong && + context.BuildOptions.ShowErrorListAfterBuild; + } + + /// + /// Runs the test for the project after a successful build. + /// + void OnBuildComplete(BuildResults results, SelectedTests selectedTests) + { + if (BuildHasNoErrorsAndStillRunningTests(results)) { + RunTests(selectedTests); + } else { + if (IsRunningTest) { + Stop(); + } + ShowErrorList(); + } + } + + bool BuildHasNoErrorsAndStillRunningTests(BuildResults results) + { + return (results.ErrorCount == 0) && IsRunningTest; + } + + void RunTests(SelectedTests selectedTests) + { + testRunner = CreateTestRunner(selectedTests.Project); + if (testRunner != null) { + testRunner.MessageReceived += TestRunnerMessageReceived; + testRunner.AllTestsFinished += AllTestsFinished; + testRunner.TestFinished += TestFinished; + testRunner.Start(selectedTests); + } + } + + protected virtual ITestRunner CreateTestRunner(IProject project) + { + return null; + } + + void TestRunnerMessageReceived(object source, MessageReceivedEventArgs e) + { + context.UnitTestCategory.AppendLine(e.Message); + } + + void AllTestsFinished(object source, EventArgs e) + { + context.Workbench.SafeThreadAsyncCall(TestRunCompleted); + } + + /// + /// Clears the test results in the test tree view for all the + /// displayed projects. + /// + void ResetAllTestResultsInUnitTestsPad() + { + unitTestsPad.ResetTestResults(); + } + + TestProject GetTestProjectForProject(IProject project) + { + return unitTestsPad.GetTestProject(project); + } + + void UpdateTestResult(TestResult result) + { + TestProject testProject = GetTestProjectForProject(selectedTests.Project); + if (testProject != null) { + testProject.UpdateTestResult(result); + } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/BuildProjectBeforeTestRun.cs b/src/AddIns/Analysis/UnitTesting/Src/BuildProjectBeforeTestRun.cs new file mode 100644 index 0000000000..d0cb7fb7ae --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/BuildProjectBeforeTestRun.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Project.Commands; + +namespace ICSharpCode.UnitTesting +{ + /// + /// Custom build command that makes sure errors and warnings + /// are not cleared from the Errors list before every build since + /// we may be running multiple tests after each other. + /// + public class BuildProjectBeforeTestRun : BuildProjectBeforeExecute + { + IUnitTestSaveAllFilesCommand saveAllFilesCommand; + + public BuildProjectBeforeTestRun(IProject targetProject, + IUnitTestSaveAllFilesCommand saveAllFilesCommand) + : base(targetProject) + { + this.saveAllFilesCommand = saveAllFilesCommand; + } + + public BuildProjectBeforeTestRun(IProject targetProject) + : this(targetProject, new UnitTestSaveAllFilesCommand()) + { + } + + /// + /// Before a build do not clear the tasks, just save any + /// dirty files. + /// + public override void BeforeBuild() + { + saveAllFilesCommand.SaveAllFiles(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs new file mode 100644 index 0000000000..7b936eca6e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/EmptyUnitTestsPad.cs @@ -0,0 +1,37 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class EmptyUnitTestsPad : IUnitTestsPad + { + public void UpdateToolbar() + { + } + + public void BringToFront() + { + } + + public void ResetTestResults() + { + } + + public IProject[] GetProjects() + { + return new IProject[0]; + } + + public TestProject GetTestProject(IProject project) + { + return null; + } + } +} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/ScrollUtils.cs b/src/AddIns/Analysis/UnitTesting/Src/IAddInTree.cs similarity index 52% rename from src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/ScrollUtils.cs rename to src/AddIns/Analysis/UnitTesting/Src/IAddInTree.cs index 4a3f8cdfbd..d094964b04 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/PresentationBindings/ScrollUtils.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/IAddInTree.cs @@ -1,16 +1,17 @@ // // // -// +// // $Revision$ // using System; using System.Collections.Generic; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Media; -namespace Debugger.AddIn.Visualizers +namespace ICSharpCode.UnitTesting { + public interface IAddInTree + { + List BuildItems(string path, object caller); + } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/IBuildOptions.cs b/src/AddIns/Analysis/UnitTesting/Src/IBuildOptions.cs new file mode 100644 index 0000000000..d94cccc166 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IBuildOptions.cs @@ -0,0 +1,16 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public interface IBuildOptions + { + bool ShowErrorListAfterBuild { get; } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IBuildProjectFactory.cs b/src/AddIns/Analysis/UnitTesting/Src/IBuildProjectFactory.cs new file mode 100644 index 0000000000..476aedf1d0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IBuildProjectFactory.cs @@ -0,0 +1,17 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public interface IBuildProjectFactory + { + BuildProjectBeforeTestRun CreateBuildProjectBeforeTestRun(IProject project); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IRegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Src/IRegisteredTestFrameworks.cs new file mode 100644 index 0000000000..a3964f1cc2 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IRegisteredTestFrameworks.cs @@ -0,0 +1,26 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public interface IRegisteredTestFrameworks + { + ITestFramework GetTestFrameworkForProject(IProject project); + ITestRunner CreateTestRunner(IProject project); + ITestRunner CreateTestDebugger(IProject project); + + bool IsTestMethod(IMember member); + bool IsTestClass(IClass c); + bool IsTestProject(IProject project); + + bool IsBuildNeededBeforeTestRunForProject(IProject project); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs new file mode 100644 index 0000000000..3910a83c9f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IRunTestCommandContext.cs @@ -0,0 +1,25 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public interface IRunTestCommandContext + { + IRegisteredTestFrameworks RegisteredTestFrameworks { get; } + IUnitTestTaskService TaskService { get; } + IUnitTestWorkbench Workbench { get; } + IBuildProjectFactory BuildProjectFactory { get; } + IBuildOptions BuildOptions { get; } + MessageViewCategory UnitTestCategory { get; } + IUnitTestsPad OpenUnitTestsPad { get; } + IUnitTestMessageService MessageService { get; } + IUnitTestSaveAllFilesCommand SaveAllFilesCommand { get; } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/ITestFrameworkFactory.cs b/src/AddIns/Analysis/UnitTesting/Src/ITestFrameworkFactory.cs new file mode 100644 index 0000000000..bab96f959e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/ITestFrameworkFactory.cs @@ -0,0 +1,16 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public interface ITestFrameworkFactory + { + ITestFramework Create(string className); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs new file mode 100644 index 0000000000..ebd4549db3 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/ITestResultsMonitor.cs @@ -0,0 +1,22 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public interface ITestResultsMonitor : IDisposable + { + event TestFinishedEventHandler TestFinished; + + string FileName { get; set; } + + void Stop(); + void Start(); + void Read(); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/ITestRunner.cs b/src/AddIns/Analysis/UnitTesting/Src/ITestRunner.cs new file mode 100644 index 0000000000..b4c0710200 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/ITestRunner.cs @@ -0,0 +1,21 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Util; + +namespace ICSharpCode.UnitTesting +{ + public interface ITestRunner : IDisposable + { + event TestFinishedEventHandler TestFinished; + event EventHandler AllTestsFinished; + event MessageReceivedEventHandler MessageReceived; + void Start(SelectedTests selectedTests); + void Stop(); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestDebuggerService.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestDebuggerService.cs new file mode 100644 index 0000000000..d3f091453c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestDebuggerService.cs @@ -0,0 +1,19 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Data; +using ICSharpCode.SharpDevelop.Debugging; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestDebuggerService + { + bool IsDebuggerLoaded { get; } + IDebugger CurrentDebugger { get; } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestFileService.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestFileService.cs new file mode 100644 index 0000000000..547fda718a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestFileService.cs @@ -0,0 +1,18 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestFileService + { + void OpenFile(string fileName); + + void JumpToFilePosition(string fileName, int line, int column); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs new file mode 100644 index 0000000000..169989ebb2 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestMessageService.cs @@ -0,0 +1,17 @@ +// +// +// +// +// $Revision$ +// + + +using System; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestMessageService + { + bool AskQuestion(string question, string caption); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestProcessRunner.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestProcessRunner.cs new file mode 100644 index 0000000000..d3a8099a22 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestProcessRunner.cs @@ -0,0 +1,25 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Util; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestProcessRunner + { + bool LogStandardOutputAndError { get; set; } + string WorkingDirectory { get; set; } + + void Start(string command, string arguments); + void Kill(); + + event LineReceivedEventHandler OutputLineReceived; + event LineReceivedEventHandler ErrorLineReceived; + event EventHandler ProcessExited; + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestSaveAllFilesCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestSaveAllFilesCommand.cs new file mode 100644 index 0000000000..86cdb41bc4 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestSaveAllFilesCommand.cs @@ -0,0 +1,16 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestSaveAllFilesCommand + { + void SaveAllFiles(); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestTaskService.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestTaskService.cs new file mode 100644 index 0000000000..e26e754d61 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestTaskService.cs @@ -0,0 +1,23 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestTaskService + { + MessageViewCategory BuildMessageViewCategory { get; } + bool InUpdate { get; set; } + void ClearExceptCommentTasks(); + void Add(Task task); + bool SomethingWentWrong { get; } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestWorkbench.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestWorkbench.cs new file mode 100644 index 0000000000..3ace159622 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestWorkbench.cs @@ -0,0 +1,19 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestWorkbench + { + PadDescriptor GetPad(Type type); + void SafeThreadAsyncCall(Action method); + void SafeThreadAsyncCall(Action method, A arg1); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs new file mode 100644 index 0000000000..cd417bba2e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/IUnitTestsPad.cs @@ -0,0 +1,21 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public interface IUnitTestsPad + { + void UpdateToolbar(); + void BringToFront(); + void ResetTestResults(); + IProject[] GetProjects(); + TestProject GetTestProject(IProject project); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/MessageReceivedEventArgs.cs b/src/AddIns/Analysis/UnitTesting/Src/MessageReceivedEventArgs.cs new file mode 100644 index 0000000000..e145d47b19 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/MessageReceivedEventArgs.cs @@ -0,0 +1,27 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public delegate void MessageReceivedEventHandler(object sender, MessageReceivedEventArgs e); + + public class MessageReceivedEventArgs : EventArgs + { + string message; + + public MessageReceivedEventArgs(string message) + { + this.message = message; + } + + public string Message { + get { return message; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleCommandLine.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleCommandLine.cs new file mode 100644 index 0000000000..c8285a796f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitConsoleCommandLine.cs @@ -0,0 +1,255 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class NUnitConsoleApplication + { + public NUnitConsoleApplication(SelectedTests selectedTests, UnitTestingOptions options) + { + Initialize(selectedTests); + InitializeOptions(options); + } + + public NUnitConsoleApplication(SelectedTests selectedTests) + { + Initialize(selectedTests); + } + + void Initialize(SelectedTests selectedTests) + { + this.selectedTests = selectedTests; + this.project = selectedTests.Project; + Assemblies.Add(project.OutputAssemblyFullPath); + if (selectedTests.NamespaceFilter != null) { + NamespaceFilter = selectedTests.NamespaceFilter; + } + if (selectedTests.Class != null) { + Fixture = selectedTests.Class.DotNetName; + if (selectedTests.Method != null) { + Test = selectedTests.Method.Name; + } + } + } + + void InitializeOptions(UnitTestingOptions options) + { + NoThread = options.NoThread; + NoLogo = options.NoLogo; + NoDots = options.NoDots; + Labels = options.Labels; + ShadowCopy = !options.NoShadow; + + if (options.CreateXmlOutputFile) { + GenerateXmlOutputFileName(); + } + } + + void GenerateXmlOutputFileName() + { + string directory = Path.GetDirectoryName(project.OutputAssemblyFullPath); + string fileName = project.AssemblyName + "-TestResult.xml"; + XmlOutputFile = Path.Combine(directory, fileName); + } + + /// + /// returns full/path/to/Tools/NUnit + /// + string WorkingDirectory { + get { return Path.Combine(FileUtility.ApplicationRootPath, @"bin\Tools\NUnit"); } + } + + /// + /// returns full/path/to/Tools/NUnit/nunit-console.exe or nunit-console-x86.exe if the + /// project platform target is x86. + /// + public string FileName { + get { + string exe = "nunit-console"; + if (ProjectUsesDotnet20Runtime(project)) { + exe += "-dotnet2"; + } + if (IsPlatformTarget32Bit(project)) { + exe += "-x86"; + } + exe += ".exe"; + return Path.Combine(WorkingDirectory, exe); + } + } + + public readonly List Assemblies = new List(); + + /// + /// Use shadow copy assemblies. Default = true. + /// + public bool ShadowCopy = true; + + /// + /// Disables the use of a separate thread to run tests on separate thread. Default = false; + /// + public bool NoThread = false; + + /// + /// Use /nologo directive. + /// + public bool NoLogo = false; + + /// + /// Use /labels directive. + /// + public bool Labels = false; + + /// + /// Use /nodots directive. + /// + public bool NoDots = false; + + /// + /// File to write xml output to. Default = null. + /// + public string XmlOutputFile; + + /// + /// Fixture to test. Null = test all fixtures. + /// + public string Fixture; + + /// + /// Test to run. Null = run all tests. Only valid together with the Fixture property. + /// + public string Test; + + /// + /// File to write test results to. + /// + public string Results; + + /// + /// The namespace that tests need to be a part of if they are to + /// be run. + /// + public string NamespaceFilter; + + IProject project; + SelectedTests selectedTests; + + public SelectedTests SelectedTests { + get { return selectedTests; } + } + + public IProject Project { + get { return project; } + } + + public ProcessStartInfo GetProcessStartInfo() + { + ProcessStartInfo startInfo = new ProcessStartInfo(); + startInfo.FileName = FileName; + startInfo.Arguments = GetArguments(); + startInfo.WorkingDirectory = WorkingDirectory; + return startInfo; + } + + /// + /// Gets the full command line to run the unit test application. + /// This is the combination of the UnitTestApplication and + /// the command line arguments. + /// + public string GetCommandLine() + { + return String.Format("\"{0}\" {1}", FileName, GetArguments()); + } + + /// + /// Gets the arguments to use on the command line to run NUnit. + /// + public string GetArguments() + { + StringBuilder b = new StringBuilder(); + foreach (string assembly in Assemblies) { + if (b.Length > 0) + b.Append(' '); + b.Append('"'); + b.Append(assembly); + b.Append('"'); + } + if (!ShadowCopy) + b.Append(" /noshadow"); + if (NoThread) + b.Append(" /nothread"); + if (NoLogo) + b.Append(" /nologo"); + if (Labels) + b.Append(" /labels"); + if (NoDots) + b.Append(" /nodots"); + if (XmlOutputFile != null) { + b.Append(" /xml=\""); + b.Append(XmlOutputFile); + b.Append('"'); + } + if (Results != null) { + b.Append(" /results=\""); + b.Append(Results); + b.Append('"'); + } + string run = null; + if (NamespaceFilter != null) { + run = NamespaceFilter; + } else if (Fixture != null) { + if (Test != null) { + run = Fixture + "." + Test; + } else { + run = Fixture; + } + } else if (Test != null) { + run = Test; + } + if (run != null) { + b.Append(" /run=\""); + b.Append(run); + b.Append('"'); + } + return b.ToString(); + } + + /// + /// Checks that the project's PlatformTarget is x86 for the active configuration. + /// + bool IsPlatformTarget32Bit(IProject project) + { + MSBuildBasedProject msbuildProject = project as MSBuildBasedProject; + if (msbuildProject != null) { + string platformTarget = msbuildProject.GetEvaluatedProperty("PlatformTarget"); + return String.Compare(platformTarget, "x86", true) == 0; + } + return false; + } + + bool ProjectUsesDotnet20Runtime(IProject project) + { + MSBuildBasedProject msbuildProject = project as MSBuildBasedProject; + if (msbuildProject != null) { + string targetFrameworkVersion = msbuildProject.GetEvaluatedProperty("TargetFrameworkVersion"); + return !String.Equals(targetFrameworkVersion, "v4.0", StringComparison.OrdinalIgnoreCase); + } + return false; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs new file mode 100644 index 0000000000..a90861f7e9 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestDebugger.cs @@ -0,0 +1,47 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Debugging; + +namespace ICSharpCode.UnitTesting +{ + public class NUnitTestDebugger : TestDebuggerBase + { + UnitTestingOptions options; + + public NUnitTestDebugger() + : this(new UnitTestDebuggerService(), + new UnitTestMessageService(), + new TestResultsMonitor(), + new UnitTestingOptions()) + { + } + + public NUnitTestDebugger(IUnitTestDebuggerService debuggerService, + IUnitTestMessageService messageService, + ITestResultsMonitor testResultsMonitor, + UnitTestingOptions options) + : base(debuggerService, messageService, testResultsMonitor) + { + this.options = options; + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options); + app.Results = base.TestResultsMonitor.FileName; + return app.GetProcessStartInfo(); + } + + protected override TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return new NUnitTestResult(testResult); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitTestFramework.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestFramework.cs new file mode 100644 index 0000000000..4adb39f3c6 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestFramework.cs @@ -0,0 +1,115 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class NUnitTestFramework : ITestFramework + { + /// + /// Determines whether the project is a test project. A project + /// is considered to be a test project if it contains a reference + /// to the NUnit.Framework assembly. + /// + public bool IsTestProject(IProject project) + { + if (project != null) { + foreach (ProjectItem projectItem in project.Items) { + ReferenceProjectItem referenceProjectItem = projectItem as ReferenceProjectItem; + if (IsNUnitFrameworkAssemblyReference(referenceProjectItem)) { + return true; + } + } + } + return false; + } + + bool IsNUnitFrameworkAssemblyReference(ReferenceProjectItem referenceProjectItem) + { + if (referenceProjectItem != null) { + string name = referenceProjectItem.ShortName; + return name.Equals("NUnit.Framework", StringComparison.OrdinalIgnoreCase); + } + return false; + } + + /// + /// Determines whether the class is a test fixture. A class + /// is considered to be a test class if it contains a TestFixture attribute. + /// + public bool IsTestClass(IClass c) + { + StringComparer nameComparer = GetNameComparer(c); + if (nameComparer != null) { + NUnitTestAttributeName testAttributeName = new NUnitTestAttributeName("TestFixture", nameComparer); + foreach (IAttribute attribute in c.Attributes) { + if (testAttributeName.IsEqual(attribute)) { + return true; + } + } + } + return false; + } + + StringComparer GetNameComparer(IClass c) + { + if (c != null) { + IProjectContent projectContent = c.ProjectContent; + if (projectContent != null) { + LanguageProperties language = projectContent.Language; + if (language != null) { + return language.NameComparer; + } + } + } + return null; + } + + /// + /// Determines whether the method is a test method. A method + /// is considered to be a test method if it contains the NUnit Test attribute. + /// If the method has parameters it cannot be a test method. + /// + public bool IsTestMethod(IMember member) + { + if (member == null) { + return false; + } + + StringComparer nameComparer = GetNameComparer(member.DeclaringType); + if (nameComparer != null) { + NUnitTestAttributeName testAttribute = new NUnitTestAttributeName("Test", nameComparer); + foreach (IAttribute attribute in member.Attributes) { + if (testAttribute.IsEqual(attribute)) { + IMethod method = (IMethod)member; + if (method.Parameters.Count == 0) { + return true; + } + } + } + } + return false; + } + + public bool IsBuildNeededBeforeTestRun { + get { return true; } + } + + public ITestRunner CreateTestRunner() + { + return new NUnitTestRunner(); + } + + public ITestRunner CreateTestDebugger() + { + return new NUnitTestDebugger(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitTestResult.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestResult.cs new file mode 100644 index 0000000000..b5d855a6e0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestResult.cs @@ -0,0 +1,41 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public class NUnitTestResult : TestResult + { + public NUnitTestResult(TestResult testResult) + : base(testResult.Name) + { + Message = testResult.Message; + ResultType = testResult.ResultType; + StackTrace = testResult.StackTrace; + } + + protected override void OnStackTraceChanged() + { + FileLineReference fileLineRef = OutputTextLineParser.GetNUnitOutputFileLineReference(StackTrace, true); + if (fileLineRef != null) { + StackTraceFilePosition = CreateFilePosition(fileLineRef); + } else { + StackTraceFilePosition = FilePosition.Empty; + } + } + + FilePosition CreateFilePosition(FileLineReference fileLineRef) + { + string fileName = Path.GetFullPath(fileLineRef.FileName); + return new FilePosition(fileName, fileLineRef.Line, fileLineRef.Column + 1); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/NUnitTestRunner.cs b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestRunner.cs new file mode 100644 index 0000000000..b8a9ca75cd --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/NUnitTestRunner.cs @@ -0,0 +1,45 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Util; + +namespace ICSharpCode.UnitTesting +{ + public class NUnitTestRunner : TestProcessRunnerBase + { + UnitTestingOptions options; + + public NUnitTestRunner() + : this(new UnitTestProcessRunner(), + new TestResultsMonitor(), + new UnitTestingOptions()) + { + } + + public NUnitTestRunner(IUnitTestProcessRunner processRunner, + ITestResultsMonitor testResultsMonitor, + UnitTestingOptions options) + : base(processRunner, testResultsMonitor) + { + this.options = options; + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options); + app.Results = base.TestResultsMonitor.FileName; + return app.GetProcessStartInfo(); + } + + protected override TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return new NUnitTestResult(testResult); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/RegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Src/RegisteredTestFrameworks.cs new file mode 100644 index 0000000000..d8e1a2dfb8 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/RegisteredTestFrameworks.cs @@ -0,0 +1,113 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class RegisteredTestFrameworks : IRegisteredTestFrameworks + { + List testFrameworkDescriptors; + public const string AddInPath = "/SharpDevelop/UnitTesting/TestFrameworks"; + + public RegisteredTestFrameworks(IAddInTree addInTree) + { + testFrameworkDescriptors = addInTree.BuildItems(AddInPath, null); + } + + public ITestFramework GetTestFrameworkForProject(IProject project) + { + if (project != null) { + foreach (TestFrameworkDescriptor descriptor in testFrameworkDescriptors) { + if (descriptor.IsSupportedProject(project)) { + return descriptor.TestFramework; + } + } + } + return null; + } + + public bool IsTestMethod(IMember member) + { + ITestFramework testFramework = GetTestFramework(member); + if (testFramework != null) { + return testFramework.IsTestMethod(member); + } + return false; + } + + ITestFramework GetTestFramework(IMember member) + { + if (member != null) { + return GetTestFramework(member.DeclaringType); + } + return null; + } + + ITestFramework GetTestFramework(IClass c) + { + IProject project = GetProject(c); + return GetTestFrameworkForProject(project); + } + + IProject GetProject(IClass c) + { + if (c != null) { + return c.ProjectContent.Project as IProject; + } + return null; + } + + public bool IsTestClass(IClass c) + { + ITestFramework testFramework = GetTestFramework(c); + if (testFramework != null) { + return testFramework.IsTestClass(c); + } + return false; + } + + public bool IsTestProject(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.IsTestProject(project); + } + return false; + } + + public ITestRunner CreateTestRunner(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.CreateTestRunner(); + } + return null; + } + + public ITestRunner CreateTestDebugger(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.CreateTestDebugger(); + } + return null; + } + + public bool IsBuildNeededBeforeTestRunForProject(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.IsBuildNeededBeforeTestRun; + } + return true; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/RunAllTestsInPadCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/RunAllTestsInPadCommand.cs new file mode 100644 index 0000000000..b1965ee555 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/RunAllTestsInPadCommand.cs @@ -0,0 +1,30 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public class RunAllTestsInPadCommand : RunTestInPadCommand + { + public RunAllTestsInPadCommand() + { + } + + public RunAllTestsInPadCommand(IRunTestCommandContext context) + : base(context) + { + } + + public override void Run() + { + // To make sure all tests are run we set the Owner to null. + Owner = null; + base.Run(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/RunProjectTestsInPadCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/RunProjectTestsInPadCommand.cs new file mode 100644 index 0000000000..b01ee8decc --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/RunProjectTestsInPadCommand.cs @@ -0,0 +1,47 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class RunProjectTestsInPadCommand : RunTestInPadCommand, ITestTreeView + { + public RunProjectTestsInPadCommand() + { + } + + public RunProjectTestsInPadCommand(IRunTestCommandContext context) + : base(context) + { + } + + public override void Run() + { + Owner = this; + base.Run(); + } + + public IMember SelectedMethod { + get { return null; } + } + + public IClass SelectedClass { + get { return null; } + } + + public IProject SelectedProject { + get { return ProjectService.CurrentProject; } + } + + public string SelectedNamespace { + get { return null; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs new file mode 100644 index 0000000000..737c517676 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/RunTestCommandContext.cs @@ -0,0 +1,61 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public class RunTestCommandContext : IRunTestCommandContext + { + UnitTestingOptions options = new UnitTestingOptions(); + IRegisteredTestFrameworks testFrameworks = TestService.RegisteredTestFrameworks; + UnitTestTaskService taskService = new UnitTestTaskService(); + UnitTestWorkbench workbench = new UnitTestWorkbench(); + UnitTestBuildProjectFactory buildProjectFactory = new UnitTestBuildProjectFactory(); + UnitTestBuildOptions buildOptions = new UnitTestBuildOptions(); + MessageViewCategory unitTestCategory = TestService.UnitTestMessageView; + UnitTestMessageService messageService = new UnitTestMessageService(); + UnitTestSaveAllFilesCommand saveAllFilesCommand = new UnitTestSaveAllFilesCommand(); + + public IRegisteredTestFrameworks RegisteredTestFrameworks { + get { return testFrameworks; } + } + + public IUnitTestTaskService TaskService { + get { return taskService; } + } + + public IUnitTestWorkbench Workbench { + get { return workbench; } + } + + public IBuildProjectFactory BuildProjectFactory { + get { return buildProjectFactory; } + } + + public IBuildOptions BuildOptions { + get { return buildOptions; } + } + + public MessageViewCategory UnitTestCategory { + get { return unitTestCategory; } + } + + public IUnitTestsPad OpenUnitTestsPad { + get { return UnitTestsPad.Instance; } + } + + public IUnitTestMessageService MessageService { + get { return messageService; } + } + + public IUnitTestSaveAllFilesCommand SaveAllFilesCommand { + get { return saveAllFilesCommand; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/RunTestInPadCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/RunTestInPadCommand.cs new file mode 100644 index 0000000000..8bb0fbbf68 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/RunTestInPadCommand.cs @@ -0,0 +1,30 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.SharpDevelop.Util; + +namespace ICSharpCode.UnitTesting +{ + public class RunTestInPadCommand : AbstractRunTestCommand + { + public RunTestInPadCommand() + { + } + + public RunTestInPadCommand(IRunTestCommandContext context) + : base(context) + { + } + + protected override ITestRunner CreateTestRunner(IProject project) + { + return Context.RegisteredTestFrameworks.CreateTestRunner(project); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/RunTestWithDebuggerCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/RunTestWithDebuggerCommand.cs new file mode 100644 index 0000000000..70ececa345 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/RunTestWithDebuggerCommand.cs @@ -0,0 +1,30 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class RunTestWithDebuggerCommand : AbstractRunTestCommand + { + public RunTestWithDebuggerCommand() + { + } + + public RunTestWithDebuggerCommand(IRunTestCommandContext context) + : base(context) + { + } + + protected override ITestRunner CreateTestRunner(IProject project) + { + return Context.RegisteredTestFrameworks.CreateTestDebugger(project); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/SelectedTests.cs b/src/AddIns/Analysis/UnitTesting/Src/SelectedTests.cs new file mode 100644 index 0000000000..1ad3df7804 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/SelectedTests.cs @@ -0,0 +1,96 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class SelectedTests + { + string namespaceFilter; + IClass c; + IMember method; + List projects = new List(); + + public SelectedTests(IProject project, string namespaceFilter, IClass c, IMember method) + { + this.namespaceFilter = namespaceFilter; + this.c = c; + this.method = method; + + if (project != null) { + projects.Add(project); + } + } + + public SelectedTests(IProject project) + : this(project, null, null, null) + { + } + + public SelectedTests(object owner, IProject[] selectedProjects) + { + IProject project = TestableCondition.GetProject(owner); + if (project != null) { + projects.Add(project); + } else { + projects.AddRange(selectedProjects); + } + + method = TestableCondition.GetMember(owner); + c = GetClass(method, owner); + namespaceFilter = TestableCondition.GetNamespace(owner); + } + + static IClass GetClass(IMember member, Object owner) + { + if (member != null) { + return member.DeclaringType; + } + return TestableCondition.GetClass(owner); + } + + public bool HasProjects { + get { return projects.Count > 0; } + } + + public void RemoveFirstProject() + { + if (HasProjects) { + projects.RemoveAt(0); + } + } + + public IList Projects { + get { return projects; } + } + + public IProject Project { + get { + if (projects.Count > 0) { + return projects[0]; + } + return null; + } + } + + public string NamespaceFilter { + get { return namespaceFilter; } + } + + public IClass Class { + get { return c; } + } + + public IMember Method { + get { return method; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestAttributeName.cs b/src/AddIns/Analysis/UnitTesting/Src/TestAttributeName.cs index 0182961b3e..cea45bd584 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestAttributeName.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestAttributeName.cs @@ -6,10 +6,11 @@ // using System; +using ICSharpCode.SharpDevelop.Dom; namespace ICSharpCode.UnitTesting { - public class TestAttributeName + public class NUnitTestAttributeName { string name = String.Empty; string qualifiedName = String.Empty; @@ -17,13 +18,13 @@ namespace ICSharpCode.UnitTesting StringComparer nameComparer; /// - /// Creates a new instance of the Test Attribute class. + /// Creates a new instance of the NUnit Test Attribute class. /// /// The name of the attribute (e.g. Test) not /// the full name of the attribute (e.g. TestAttribute). /// The string comparer to use /// when comparing attribute names. - public TestAttributeName(string name, StringComparer nameComparer) + public NUnitTestAttributeName(string name, StringComparer nameComparer) { this.name = name; this.nameComparer = nameComparer; @@ -44,5 +45,10 @@ namespace ICSharpCode.UnitTesting } return false; } + + public bool IsEqual(IAttribute attribute) + { + return IsEqual(attribute.AttributeType.FullyQualifiedName); + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestClass.cs b/src/AddIns/Analysis/UnitTesting/Src/TestClass.cs index 9c8a54d0cd..38e999a7a2 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestClass.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestClass.cs @@ -13,24 +13,24 @@ using ICSharpCode.SharpDevelop.Dom; namespace ICSharpCode.UnitTesting { /// - /// Represents a class that can be tested. In order for a - /// class to be considered to be testable it needs to have the - /// [TestFixture] attribute. + /// Represents a class that can be tested. /// public class TestClass { IClass c; TestMethodCollection testMethods; TestResultType testResultType; + IRegisteredTestFrameworks testFrameworks; /// /// Raised when the test class result is changed. /// public event EventHandler ResultChanged; - public TestClass(IClass c) + public TestClass(IClass c, IRegisteredTestFrameworks testFrameworks) { this.c = c; + this.testFrameworks = testFrameworks; } /// @@ -40,42 +40,6 @@ namespace ICSharpCode.UnitTesting get { return c; } } - /// - /// Determines whether the class is a test fixture. A class - /// is considered to be a test class if it contains certain - /// test attributes. - /// - public static bool IsTestClass(IClass c) - { - StringComparer nameComparer = GetNameComparer(c); - if (nameComparer != null) { - TestAttributeName testAttributeName = new TestAttributeName("TestFixture", nameComparer); - foreach (IAttribute attribute in c.Attributes) { - if (testAttributeName.IsEqual(attribute.AttributeType.FullyQualifiedName)) { - return true; - } - } - } - return false; - } - - /// - /// Returns the name comparer for the specified class. - /// - public static StringComparer GetNameComparer(IClass c) - { - if (c != null) { - IProjectContent projectContent = c.ProjectContent; - if (projectContent != null) { - LanguageProperties language = projectContent.Language; - if (language != null) { - return language.NameComparer; - } - } - } - return null; - } - /// /// Gets the test classes that exist in the specified namespace. /// @@ -311,11 +275,11 @@ namespace ICSharpCode.UnitTesting /// /// Gets the test methods for the specified class. /// - static TestMethodCollection GetTestMethods(IClass c) + TestMethodCollection GetTestMethods(IClass c) { TestMethodCollection testMethods = new TestMethodCollection(); foreach (IMethod method in c.Methods) { - if (TestMethod.IsTestMethod(method)) { + if (IsTestMethod(method)) { if (!testMethods.Contains(method.Name)) { testMethods.Add(new TestMethod(method)); } @@ -326,7 +290,7 @@ namespace ICSharpCode.UnitTesting IClass declaringType = c; while (c.BaseClass != null) { foreach (IMethod method in c.BaseClass.Methods) { - if (TestMethod.IsTestMethod(method)) { + if (IsTestMethod(method)) { BaseTestMethod baseTestMethod = new BaseTestMethod(declaringType, method); TestMethod testMethod = new TestMethod(c.BaseClass.Name, baseTestMethod); if (method.IsVirtual) { @@ -345,6 +309,11 @@ namespace ICSharpCode.UnitTesting return testMethods; } + bool IsTestMethod(IMember method) + { + return testFrameworks.IsTestMethod(method); + } + /// /// Updates the test class's test result after the test method's /// test result has changed. diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs b/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs new file mode 100644 index 0000000000..5310545a37 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestDebuggerBase.cs @@ -0,0 +1,112 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Debugging; + +namespace ICSharpCode.UnitTesting +{ + public abstract class TestDebuggerBase : TestRunnerBase + { + IUnitTestDebuggerService debuggerService; + IUnitTestMessageService messageService; + IDebugger debugger; + ITestResultsMonitor testResultsMonitor; + + public TestDebuggerBase() + : this(new UnitTestDebuggerService(), + new UnitTestMessageService(), + new TestResultsMonitor()) + { + } + + public TestDebuggerBase(IUnitTestDebuggerService debuggerService, + IUnitTestMessageService messageService, + ITestResultsMonitor testResultsMonitor) + { + this.debuggerService = debuggerService; + this.messageService = messageService; + this.testResultsMonitor = testResultsMonitor; + this.debugger = debuggerService.CurrentDebugger; + + testResultsMonitor.TestFinished += OnTestFinished; + } + + protected ITestResultsMonitor TestResultsMonitor { + get { return testResultsMonitor; } + } + + public override void Start(SelectedTests selectedTests) + { + ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests); + if (IsDebuggerRunning) { + if (CanStopDebugging()) { + debugger.Stop(); + Start(startInfo); + } + } else { + Start(startInfo); + } + } + + public bool IsDebuggerRunning { + get { return debuggerService.IsDebuggerLoaded && debugger.IsDebugging; } + } + + bool CanStopDebugging() + { + string question = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}"; + string caption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}"; + return messageService.AskQuestion(question, caption); + } + + void Start(ProcessStartInfo startInfo) + { + testResultsMonitor.Start(); + StartDebugger(startInfo); + } + + void StartDebugger(ProcessStartInfo startInfo) + { + LogCommandLine(startInfo); + + bool running = false; + debugger.DebugStopped += DebugStopped; + try { + debugger.Start(startInfo); + running = true; + } finally { + if (!running) { + debugger.DebugStopped -= DebugStopped; + } + } + } + + void DebugStopped(object source, EventArgs e) + { + debugger.DebugStopped -= DebugStopped; + OnAllTestsFinished(source, e); + } + + public override void Stop() + { + if (debugger.IsDebugging) { + debugger.Stop(); + } + + testResultsMonitor.Stop(); + testResultsMonitor.Read(); + } + + public override void Dispose() + { + Stop(); + testResultsMonitor.Dispose(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestFinishedEventArgs.cs b/src/AddIns/Analysis/UnitTesting/Src/TestFinishedEventArgs.cs index b3d8f1274f..473333a1db 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestFinishedEventArgs.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestFinishedEventArgs.cs @@ -9,6 +9,8 @@ using System; namespace ICSharpCode.UnitTesting { + public delegate void TestFinishedEventHandler(object source, TestFinishedEventArgs e); + public class TestFinishedEventArgs : EventArgs { TestResult result; @@ -19,9 +21,7 @@ namespace ICSharpCode.UnitTesting } public TestResult Result { - get { - return result; - } + get { return result; } } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestFramework.cs b/src/AddIns/Analysis/UnitTesting/Src/TestFramework.cs new file mode 100644 index 0000000000..fbddc3976d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestFramework.cs @@ -0,0 +1,25 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public interface ITestFramework + { + bool IsTestMethod(IMember member); + bool IsTestClass(IClass c); + bool IsTestProject(IProject project); + + ITestRunner CreateTestRunner(); + ITestRunner CreateTestDebugger(); + + bool IsBuildNeededBeforeTestRun { get; } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkDescriptor.cs b/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkDescriptor.cs new file mode 100644 index 0000000000..e97c0a67ab --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkDescriptor.cs @@ -0,0 +1,81 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.IO; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class TestFrameworkDescriptor + { + Properties properties; + ITestFrameworkFactory factory; + ITestFramework testFramework; + List supportedProjectFileExtensions = new List(); + + public TestFrameworkDescriptor(Properties properties, ITestFrameworkFactory factory) + { + this.properties = properties; + this.factory = factory; + + GetSupportedProjectFileExtensions(); + } + + void GetSupportedProjectFileExtensions() + { + string extensions = properties["supportedProjects"]; + + foreach (string extension in extensions.Split(';')) { + supportedProjectFileExtensions.Add(extension.ToLowerInvariant().Trim()); + } + } + + public string Id { + get { return properties["id"]; } + } + + public ITestFramework TestFramework { + get { + CreateTestFrameworkIfNotCreated(); + return testFramework; + } + } + + void CreateTestFrameworkIfNotCreated() + { + if (testFramework == null) { + testFramework = factory.Create(ClassName); + } + } + + string ClassName { + get { return properties["class"]; } + } + + public bool IsSupportedProject(IProject project) + { + string extension = GetProjectFileExtension(project); + return IsSupportedProjectFileExtension(extension); + } + + string GetProjectFileExtension(IProject project) + { + if (project != null) { + return Path.GetExtension(project.FileName).ToLowerInvariant(); + } + return null; + } + + bool IsSupportedProjectFileExtension(string extension) + { + return supportedProjectFileExtensions.Contains(extension); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkDoozer.cs b/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkDoozer.cs new file mode 100644 index 0000000000..0ec68001f9 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkDoozer.cs @@ -0,0 +1,34 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections; +using ICSharpCode.Core; + +namespace ICSharpCode.UnitTesting +{ + public class TestFrameworkDoozer : IDoozer + { + public TestFrameworkDoozer() + { + } + + public bool HandleConditions { + get { return false; } + } + + public object BuildItem(object caller, Codon codon, ArrayList subItems) + { + return BuildItem(codon, new TestFrameworkFactory(codon.AddIn)); + } + + public TestFrameworkDescriptor BuildItem(Codon codon, ITestFrameworkFactory factory) + { + return new TestFrameworkDescriptor(codon.Properties, factory); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkFactory.cs b/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkFactory.cs new file mode 100644 index 0000000000..a67547a094 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestFrameworkFactory.cs @@ -0,0 +1,27 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; + +namespace ICSharpCode.UnitTesting +{ + public class TestFrameworkFactory : ITestFrameworkFactory + { + AddIn addin; + + public TestFrameworkFactory(AddIn addin) + { + this.addin = addin; + } + + public ITestFramework Create(string className) + { + return addin.CreateObject(className) as ITestFramework; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestMethod.cs b/src/AddIns/Analysis/UnitTesting/Src/TestMethod.cs index f2c8e191c1..15eb2195fa 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestMethod.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestMethod.cs @@ -11,8 +11,7 @@ using ICSharpCode.SharpDevelop.Dom; namespace ICSharpCode.UnitTesting { /// - /// Represents a method that has the [Test] attribute and - /// can be tested. + /// Represents a method that can be tested. /// public class TestMethod { @@ -56,9 +55,7 @@ namespace ICSharpCode.UnitTesting /// Gets the underlying IMethod for this TestMethod. /// public IMethod Method { - get { - return method; - } + get { return method; } } /// @@ -74,9 +71,7 @@ namespace ICSharpCode.UnitTesting /// Gets the test result for this method. /// public TestResultType Result { - get { - return testResultType; - } + get { return testResultType; } set { TestResultType previousTestResultType = testResultType; testResultType = value; @@ -98,33 +93,6 @@ namespace ICSharpCode.UnitTesting } } - /// - /// Determines whether the method is a test method. A method - /// is considered to be a test method if it contains certain - /// test attributes. If the method has parameters it cannot - /// be a test method. - /// - public static bool IsTestMethod(IMember member) - { - if (member == null) { - return false; - } - - StringComparer nameComparer = TestClass.GetNameComparer(member.DeclaringType); - if (nameComparer != null) { - TestAttributeName testAttribute = new TestAttributeName("Test", nameComparer); - foreach (IAttribute attribute in member.Attributes) { - if (testAttribute.IsEqual(attribute.AttributeType.FullyQualifiedName)) { - IMethod method = (IMethod)member; - if (method.Parameters.Count == 0) { - return true; - } - } - } - } - return false; - } - /// /// Returns the method name from a fully qualified name /// of the form: diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBase.cs b/src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBase.cs new file mode 100644 index 0000000000..902b7c2f13 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestProcessRunnerBase.cs @@ -0,0 +1,82 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Util; + +namespace ICSharpCode.UnitTesting +{ + public class TestProcessRunnerBase : TestRunnerBase + { + IUnitTestProcessRunner processRunner; + ITestResultsMonitor testResultsMonitor; + + public TestProcessRunnerBase() + : this(new UnitTestProcessRunner(), + new TestResultsMonitor()) + { + } + + public TestProcessRunnerBase(IUnitTestProcessRunner processRunner, + ITestResultsMonitor testResultsMonitor) + { + this.processRunner = processRunner; + this.testResultsMonitor = testResultsMonitor; + + processRunner.LogStandardOutputAndError = false; + processRunner.OutputLineReceived += OutputLineReceived; + processRunner.ErrorLineReceived += OutputLineReceived; + processRunner.ProcessExited += OnAllTestsFinished; + testResultsMonitor.TestFinished += OnTestFinished; + } + + protected ITestResultsMonitor TestResultsMonitor { + get { return testResultsMonitor; } + } + +// public override event EventHandler AllTestsFinished { +// add { processRunner.ProcessExited += value; } +// remove { processRunner.ProcessExited -= value; } +// } + + void OutputLineReceived(object source, LineReceivedEventArgs e) + { + OnMessageReceived(e.Line); + } + + public override void Start(SelectedTests selectedTests) + { + ProcessStartInfo startInfo = GetProcessStartInfo(selectedTests); + Start(startInfo); + } + + void Start(ProcessStartInfo processStartInfo) + { + LogCommandLine(processStartInfo); + + testResultsMonitor.Start(); + processRunner.WorkingDirectory = processStartInfo.WorkingDirectory; + processRunner.Start(processStartInfo.FileName, processStartInfo.Arguments); + } + + public override void Stop() + { + processRunner.Kill(); + testResultsMonitor.Stop(); + testResultsMonitor.Read(); + } + + public override void Dispose() + { + testResultsMonitor.Dispose(); + testResultsMonitor.TestFinished -= OnTestFinished; + processRunner.ErrorLineReceived -= OutputLineReceived; + processRunner.OutputLineReceived -= OutputLineReceived; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestProject.cs b/src/AddIns/Analysis/UnitTesting/Src/TestProject.cs index f42f069e4e..d2e40349f0 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestProject.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestProject.cs @@ -23,53 +23,19 @@ namespace ICSharpCode.UnitTesting IProjectContent projectContent; TestClassCollection testClasses; List rootNamespaces; + IRegisteredTestFrameworks testFrameworks; - public TestProject(IProject project, IProjectContent projectContent) + public TestProject(IProject project, IProjectContent projectContent, IRegisteredTestFrameworks testFrameworks) { this.project = project; this.projectContent = projectContent; + this.testFrameworks = testFrameworks; } - /// - /// Returns the underlying project. - /// public IProject Project { get { return project; } } - /// - /// Determines whether the project is a test project. A project - /// is considered to be a test project if it contains a reference - /// to the NUnit.Framework assembly. - /// - public static bool IsTestProject(IProject project) - { - if (project != null) { - foreach (ProjectItem projectItem in project.Items) { - ReferenceProjectItem referenceProjectItem = projectItem as ReferenceProjectItem; - if (referenceProjectItem != null) { - if (IsTestFrameworkReference(referenceProjectItem)) { - return true; - } - } - } - } - return false; - } - - /// - /// Determines whether the specified reference is a reference to - /// a test framework. Currently only references to the - /// NUnit.Framework return true. - /// - public static bool IsTestFrameworkReference(ReferenceProjectItem referenceProjectItem) - { - if (referenceProjectItem != null) { - return string.Equals(referenceProjectItem.ShortName, "NUnit.Framework", StringComparison.OrdinalIgnoreCase); - } - return false; - } - /// /// Gets the test classes in this project. /// @@ -209,12 +175,17 @@ namespace ICSharpCode.UnitTesting /// void AddNewTestClass(IClass c) { - if (TestClass.IsTestClass(c)) { - TestClass testClass = new TestClass(c); + if (IsTestClass(c)) { + TestClass testClass = CreateTestClass(c); TestClasses.Add(testClass); } } + TestClass CreateTestClass(IClass c) + { + return new TestClass(c, testFrameworks); + } + /// /// Updates the test class methods based on the newly parsed class /// information. @@ -222,7 +193,7 @@ namespace ICSharpCode.UnitTesting void UpdateTestClass(IClass c) { if (TestClasses.Contains(c.DotNetName)) { - if (TestClass.IsTestClass(c)) { + if (IsTestClass(c)) { TestClass testClass = TestClasses[c.DotNetName]; testClass.UpdateClass(c); } else { @@ -236,38 +207,43 @@ namespace ICSharpCode.UnitTesting // check if the class is actually a test class since // AddNewTestClass does this anyway. AddNewTestClass(c); - } + } } void GetTestClasses() { testClasses = new TestClassCollection(); foreach (IClass c in projectContent.Classes) { - if (TestClass.IsTestClass(c)) { + if (IsTestClass(c)) { if (!testClasses.Contains(c.FullyQualifiedName)) { - testClasses.Add(new TestClass(c)); + testClasses.Add(CreateTestClass(c)); } } foreach (IClass innerClass in c.InnerClasses) { - if (TestClass.IsTestClass(innerClass)) { + if (IsTestClass(innerClass)) { if (!testClasses.Contains(innerClass.DotNetName)) { - testClasses.Add(new TestClass(innerClass)); + testClasses.Add(CreateTestClass(innerClass)); } } } } } + bool IsTestClass(IClass c) + { + return testFrameworks.IsTestClass(c); + } + void GetRootNamespaces() { rootNamespaces = new List(); foreach (TestClass c in TestClasses) { string rootNamespace = c.RootNamespace; - if (rootNamespace.Length > 0 && !rootNamespaces.Contains(rootNamespace)) { + if ((rootNamespace.Length > 0) && !rootNamespaces.Contains(rootNamespace)) { rootNamespaces.Add(rootNamespace); } } - } + } /// /// Gets an existing test class with the same name in the project. This @@ -277,7 +253,7 @@ namespace ICSharpCode.UnitTesting IClass GetExistingTestClassInProject(IClass c) { foreach (IClass existingClass in projectContent.Classes) { - if (TestClass.IsTestClass(existingClass)) { + if (IsTestClass(existingClass)) { if (existingClass.DotNetName == c.DotNetName) { return existingClass; } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestResult.cs b/src/AddIns/Analysis/UnitTesting/Src/TestResult.cs index e5463047e4..4d36ce826f 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestResult.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestResult.cs @@ -6,6 +6,7 @@ // using System; +using ICSharpCode.SharpDevelop.Dom; namespace ICSharpCode.UnitTesting { @@ -40,6 +41,7 @@ namespace ICSharpCode.UnitTesting string message = String.Empty; string stackTrace = String.Empty; TestResultType resultType = TestResultType.None; + FilePosition stackTraceFilePosition = FilePosition.Empty; public TestResult(string name) { @@ -47,60 +49,48 @@ namespace ICSharpCode.UnitTesting } public string Name { - get { - return name; - } + get { return name; } } public bool IsSuccess { - get { - return resultType == TestResultType.Success; - } - set { - resultType = TestResultType.Success; - } + get { return resultType == TestResultType.Success; } } public bool IsFailure { - get { - return resultType == TestResultType.Failure; - } - set { - resultType = TestResultType.Failure; - } + get { return resultType == TestResultType.Failure; } } public bool IsIgnored { - get { - return resultType == TestResultType.Ignored; - } - set { - resultType = TestResultType.Ignored; - } + get { return resultType == TestResultType.Ignored; } } public TestResultType ResultType { - get { - return resultType; - } + get { return resultType; } + set { resultType = value; } } public string Message { - get { - return message; - } - set { - message = value; - } + get { return message; } + set { message = value; } } public string StackTrace { - get { - return stackTrace; - } + get { return stackTrace; } set { - stackTrace = value; + if (stackTrace != value) { + stackTrace = value; + OnStackTraceChanged(); + } } } + + protected virtual void OnStackTraceChanged() + { + } + + public FilePosition StackTraceFilePosition { + get { return stackTraceFilePosition; } + set { stackTraceFilePosition = value; } + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestResultTask.cs b/src/AddIns/Analysis/UnitTesting/Src/TestResultTask.cs new file mode 100644 index 0000000000..703430907f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestResultTask.cs @@ -0,0 +1,102 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public class TestResultTask + { + TestResultTask() + { + } + + public static Task Create(TestResult result, TestProject project) + { + TaskType taskType = TaskType.Warning; + FileLineReference lineRef = null; + string message = String.Empty; + + if (result.IsFailure) { + taskType = TaskType.Error; + if (!result.StackTraceFilePosition.IsEmpty) { + lineRef = new FileLineReference(result.StackTraceFilePosition.FileName, result.StackTraceFilePosition.Line - 1, result.StackTraceFilePosition.Column - 1); + } + message = GetTestFailedMessage(result); + } else if (result.IsIgnored) { + message = GetTestIgnoredMessage(result); + } + if (lineRef == null) { + lineRef = FindTest(result.Name, project); + } + FileName fileName = null; + if (lineRef != null) { + fileName = new FileName(Path.GetFullPath(lineRef.FileName)); + int line = lineRef.Line + 1; + return new Task(fileName, message, lineRef.Column, line, taskType); + } + return new Task(fileName, message, 0, 0, taskType); + } + + static string GetTestFailedMessage(TestResult result) + { + string resource = "${res:NUnitPad.NUnitPadContent.TestTreeView.TestFailedMessage}"; + return GetTestResultMessage(result, resource); + } + + static string GetTestIgnoredMessage(TestResult result) + { + string resource = "${res:NUnitPad.NUnitPadContent.TestTreeView.TestNotExecutedMessage}"; + return GetTestResultMessage(result, resource); + } + + /// + /// Returns the test result message if there is on otherwise + /// uses the string resource to create a message. + /// + static string GetTestResultMessage(TestResult result, string stringResource) + { + if (result.Message.Length > 0) { + return result.Message; + } + return GetTestResultMessageFromResource(result, stringResource); + } + + static string GetTestResultMessageFromResource(TestResult result, string stringResource) + { + string [,] customTags = new string[,] {{"TestCase", result.Name}}; + return StringParser.Parse(stringResource, customTags); + } + + /// + /// Returns the location of the specified test method in the + /// project being tested. + /// + static FileLineReference FindTest(string methodName, TestProject testProject) + { + if (testProject != null) { + TestMethod testMethod = testProject.TestClasses.GetTestMethod(methodName); + if (testMethod != null) { + return FindTest(testMethod); + } + } + return null; + } + + static FileLineReference FindTest(TestMethod testMethod) + { + MemberResolveResult resolveResult = new MemberResolveResult(null, null, testMethod.Method); + FilePosition filePos = resolveResult.GetDefinitionPosition(); + return new FileLineReference(filePos.FileName, filePos.Line - 1, filePos.Column - 1); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs index cab72561c3..d29efc4396 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestResultsMonitor.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.UnitTesting /// Watches for new test results as they occur. Test results /// are written to a file and read in by this class. /// - public class TestResultsMonitor : IDisposable + public class TestResultsMonitor : ITestResultsMonitor { FileInfo fileInfo; TestResultsReader testResultsReader; @@ -25,8 +25,6 @@ namespace ICSharpCode.UnitTesting const int BytesBufferLength = 1024; byte[] bytes = new byte[BytesBufferLength]; - public delegate void TestFinishedEventHandler(object source, TestFinishedEventArgs e); - /// /// Raised when a single test has been completed. /// @@ -39,6 +37,7 @@ namespace ICSharpCode.UnitTesting } public TestResultsMonitor() + : this(Path.GetTempFileName()) { ResetFilePosition(); } @@ -47,12 +46,8 @@ namespace ICSharpCode.UnitTesting /// Gets or sets the test results filename. /// public string FileName { - get { - return fileInfo.FullName; - } - set { - fileInfo = new FileInfo(value); - } + get { return fileInfo.FullName; } + set { fileInfo = new FileInfo(value); } } /// @@ -80,7 +75,7 @@ namespace ICSharpCode.UnitTesting /// Stops monitoring. /// public void Stop() - { + { if (fileSystemWatcher != null) { fileSystemWatcher.Dispose(); fileSystemWatcher = null; @@ -108,6 +103,10 @@ namespace ICSharpCode.UnitTesting public void Dispose() { Stop(); + + try { + File.Delete(FileName); + } catch { } } void FileCreated(object source, FileSystemEventArgs e) @@ -124,7 +123,7 @@ namespace ICSharpCode.UnitTesting void OnTestResultsReceived(TestResult[] results) { - if (results.Length > 0 && TestFinished != null) { + if ((results.Length > 0) && (TestFinished != null)) { foreach (TestResult result in results) { TestFinished(this, new TestFinishedEventArgs(result)); } @@ -150,7 +149,7 @@ namespace ICSharpCode.UnitTesting filePosition += bytesRead; text.Append(UTF8Encoding.UTF8.GetString(bytes, 0, bytesRead)); } - } while (bytesRead > 0 && filePosition < fs.Length); + } while ((bytesRead > 0) && (filePosition < fs.Length)); } } } catch (FileNotFoundException) { diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestResultsReader.cs b/src/AddIns/Analysis/UnitTesting/Src/TestResultsReader.cs index a0eef4fef5..5871365a63 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestResultsReader.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestResultsReader.cs @@ -147,12 +147,12 @@ namespace ICSharpCode.UnitTesting void UpdateTestSuccess() { string value = valueBuilder.ToString(); - if (value =="Success") { - result.IsSuccess = true; + if (value == "Success") { + result.ResultType = TestResultType.Success; } else if (value == "Failure") { - result.IsFailure = true; + result.ResultType = TestResultType.Failure; } else { - result.IsIgnored = true; + result.ResultType = TestResultType.Ignored; } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestRunnerBase.cs b/src/AddIns/Analysis/UnitTesting/Src/TestRunnerBase.cs new file mode 100644 index 0000000000..43c5b48f71 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestRunnerBase.cs @@ -0,0 +1,72 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; + +namespace ICSharpCode.UnitTesting +{ + public abstract class TestRunnerBase : ITestRunner + { + public TestRunnerBase() + { + } + + protected virtual ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + return new ProcessStartInfo(); + } + + protected void LogCommandLine(ProcessStartInfo startInfo) + { + string commandLine = GetCommandLine(startInfo); + OnMessageReceived(commandLine); + } + + protected string GetCommandLine(ProcessStartInfo startInfo) + { + return String.Format("\"{0}\" {1}", startInfo.FileName, startInfo.Arguments); + } + + public event EventHandler AllTestsFinished; + + protected void OnAllTestsFinished(object source, EventArgs e) + { + if (AllTestsFinished != null) { + AllTestsFinished(source, e); + } + } + + public event TestFinishedEventHandler TestFinished; + + protected void OnTestFinished(object source, TestFinishedEventArgs e) + { + if (TestFinished != null) { + TestResult testResult = CreateTestResultForTestFramework(e.Result); + TestFinished(source, new TestFinishedEventArgs(testResult)); + } + } + + protected virtual TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return testResult; + } + + public event MessageReceivedEventHandler MessageReceived; + + protected virtual void OnMessageReceived(string message) + { + if (MessageReceived != null) { + MessageReceived(this, new MessageReceivedEventArgs(message)); + } + } + + public abstract void Dispose(); + public abstract void Stop(); + public abstract void Start(SelectedTests selectedTests); + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestService.cs b/src/AddIns/Analysis/UnitTesting/Src/TestService.cs new file mode 100644 index 0000000000..9c7b07a396 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/TestService.cs @@ -0,0 +1,51 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public static class TestService + { + static IRegisteredTestFrameworks testFrameworks; + static MessageViewCategory unitTestMessageView; + + public static IRegisteredTestFrameworks RegisteredTestFrameworks { + get { + CreateRegisteredTestFrameworks(); + return testFrameworks; + } + set { testFrameworks = value; } + } + + static void CreateRegisteredTestFrameworks() + { + if (testFrameworks == null) { + UnitTestAddInTree addInTree = new UnitTestAddInTree(); + testFrameworks = new RegisteredTestFrameworks(addInTree); + } + } + + public static MessageViewCategory UnitTestMessageView { + get { + if (unitTestMessageView == null) { + CreateUnitTestCategory(); + } + return unitTestMessageView; + } + } + + static void CreateUnitTestCategory() + { + MessageViewCategory.Create(ref unitTestMessageView, + "UnitTesting", + "${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}"); + } + + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Src/TestTreeView.cs index 1759f32251..e39d37a8d5 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestTreeView.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestTreeView.cs @@ -37,9 +37,11 @@ namespace ICSharpCode.UnitTesting /// only one test project then no such node will be added. /// AllTestsTreeNode allTestsNode; + IRegisteredTestFrameworks testFrameworks; - public TestTreeView() + public TestTreeView(IRegisteredTestFrameworks testFrameworks) { + this.testFrameworks = testFrameworks; ImageList = TestTreeViewImageList.ImageList; CanClearSelection = false; } @@ -50,7 +52,7 @@ namespace ICSharpCode.UnitTesting public Enum InternalState { get { TestTreeNode selectedNode = SelectedNode as TestTreeNode; - if (selectedNode is TestClassTreeNode || selectedNode is TestMethodTreeNode) { + if ((selectedNode is TestClassTreeNode) || (selectedNode is TestMethodTreeNode)) { return TestTreeViewState.SourceCodeItemSelected; } return TestTreeViewState.None; @@ -81,7 +83,7 @@ namespace ICSharpCode.UnitTesting /// /// Adds the project to the test tree view if the project - /// has a reference to a supported test framework. + /// is a test project. /// /// /// If the project is already in the tree then it will @@ -90,24 +92,58 @@ namespace ICSharpCode.UnitTesting /// public void AddProject(IProject project) { - if (TestProject.IsTestProject(project)) { + if (IsTestProject(project)) { if (GetProjectTreeNode(project) == null) { - // Add a new tree node. - IProjectContent projectContent = GetProjectContent(project); - if (projectContent != null) { - TestProject testProject = new TestProject(project, projectContent); - TestProjectTreeNode node = new TestProjectTreeNode(testProject); - - if (Nodes.Count == 0) { - node.AddTo(this); - } else { - AllTestsTreeNode allTestsNode = GetAllTestsNode(); - allTestsNode.AddProjectNode(node); - } - - // Sort the nodes. - SortNodes(Nodes, true); - } + AddProjectTreeNode(project); + } + } + } + + bool IsTestProject(IProject project) + { + return testFrameworks.IsTestProject(project); + } + + void AddProjectTreeNode(IProject project) + { + TestProjectTreeNode node = CreateProjectTreeNode(project); + if (node != null) { + AddProjectTreeNodeToTree(node); + SortNodes(Nodes, true); + } + } + + TestProjectTreeNode CreateProjectTreeNode(IProject project) + { + IProjectContent projectContent = GetProjectContent(project); + if (projectContent != null) { + TestProject testProject = new TestProject(project, projectContent, testFrameworks); + return new TestProjectTreeNode(testProject); + } + return null; + } + + void AddProjectTreeNodeToTree(TestProjectTreeNode node) + { + if (Nodes.Count == 0) { + node.AddTo(this); + } else { + AllTestsTreeNode allTestsNode = GetAllTestsNode(); + allTestsNode.AddProjectNode(node); + } + } + + public void RemoveSolutionFolder(ISolutionFolder solutionFolder) + { + IProject project = solutionFolder as IProject; + if (project != null) { + RemoveProject(project); + } + + ISolutionFolderContainer solutionFolderContainer = solutionFolder as ISolutionFolderContainer; + if (solutionFolderContainer != null) { + foreach (ISolutionFolder subSolutionFolder in solutionFolderContainer.Folders) { + RemoveSolutionFolder(subSolutionFolder); } } } @@ -119,11 +155,15 @@ namespace ICSharpCode.UnitTesting { TestProjectTreeNode projectNode = GetProjectTreeNode(project); RemoveProjectNode(projectNode); - - // Remove the All Tests node if it exists and there - // is only one project tree node left. - if (allTestsNode != null && GetProjectNodes().Count == 1) { - RemoveAllTestsNode(); + RemoveAllTestsNodeIfOnlyOneProjectLeft(); + } + + void RemoveAllTestsNodeIfOnlyOneProjectLeft() + { + if (allTestsNode != null) { + if (GetProjectNodes().Count == 1) { + RemoveAllTestsNode(); + } } } @@ -133,8 +173,6 @@ namespace ICSharpCode.UnitTesting public IProject[] GetProjects() { List projects = new List(); - - // Get the project information. foreach (TestProjectTreeNode projectNode in GetProjectNodes()) { projects.Add(projectNode.Project); } @@ -172,12 +210,8 @@ namespace ICSharpCode.UnitTesting public IClass SelectedClass { get { TestClassTreeNode classNode = SelectedNode as TestClassTreeNode; - if (classNode == null) { - TestMethodTreeNode methodNode = SelectedNode as TestMethodTreeNode; - if (methodNode != null) { - classNode = methodNode.Parent as TestClassTreeNode; - } + classNode = GetClassNodeFromSelectedMethodNode(); } if (classNode != null) { @@ -187,6 +221,15 @@ namespace ICSharpCode.UnitTesting } } + TestClassTreeNode GetClassNodeFromSelectedMethodNode() + { + TestMethodTreeNode methodNode = SelectedNode as TestMethodTreeNode; + if (methodNode != null) { + return methodNode.Parent as TestClassTreeNode; + } + return null; + } + /// /// Gets the project associated with the currently selected /// tree node. @@ -261,25 +304,6 @@ namespace ICSharpCode.UnitTesting return ParserService.GetProjectContent(project); } - /// - /// Adds or removes a project from the test tree view based on - /// whether a reference to a testing framework has been added or - /// removed. - /// - public void ProjectReferencesChanged(IProject project) - { - TestProjectTreeNode projectNode = GetProjectTreeNode(project); - if (TestProject.IsTestProject(project)) { - if (projectNode == null) { - TestProject testProject = new TestProject(project, GetProjectContent(project)); - projectNode = new TestProjectTreeNode(testProject); - projectNode.AddTo(this); - } - } else { - RemoveProjectNode(projectNode); - } - } - /// /// A tree node has been selected. Here we make sure the tree node /// uses the context menu strip that the tree view is using. This @@ -375,7 +399,6 @@ namespace ICSharpCode.UnitTesting /// void RemoveAllTestsNode() { - // Remove the all tests node. allTestsNode.Remove(); // Copy project nodes to the root. @@ -383,7 +406,6 @@ namespace ICSharpCode.UnitTesting Nodes.Add(node); } - // Dispose the all tests node. AllTestsNodeDisposed(null, null); } @@ -397,5 +419,21 @@ namespace ICSharpCode.UnitTesting allTestsNode.Disposed -= AllTestsNodeDisposed; allTestsNode = null; } + + /// + /// Adds the test project to the test tree view if it is now recognised as a + /// test project and is not already in the test tree. + /// + public void ProjectItemAdded(ProjectItem projectItem) + { + AddProject(projectItem.Project); + } + + public void ProjectItemRemoved(ProjectItem projectItem) + { + if (!testFrameworks.IsTestProject(projectItem.Project)) { + RemoveProject(projectItem.Project); + } + } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/TestableCondition.cs b/src/AddIns/Analysis/UnitTesting/Src/TestableCondition.cs index 6ca1e84c5c..b723129ea4 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/TestableCondition.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/TestableCondition.cs @@ -19,6 +19,18 @@ namespace ICSharpCode.UnitTesting /// public class TestableCondition : IConditionEvaluator { + IRegisteredTestFrameworks testFrameworks; + + public TestableCondition(IRegisteredTestFrameworks testFrameworks) + { + this.testFrameworks = testFrameworks; + } + + public TestableCondition() + : this(TestService.RegisteredTestFrameworks) + { + } + public static IMember GetMember(object caller) { ITestTreeView testTreeView = caller as ITestTreeView; @@ -61,9 +73,22 @@ namespace ICSharpCode.UnitTesting if (testTreeView != null) { return testTreeView.SelectedProject; } + IClass c = GetClassFromMemberOrCaller(caller); + return GetProject(c); + } + + static IClass GetClassFromMemberOrCaller(object caller) + { IMember m = GetMember(caller); - IClass c = (m != null) ? m.DeclaringType : GetClass(caller); - if (c != null && c.ProjectContent != null) { + if (m != null) { + return m.DeclaringType; + } + return GetClass(caller); + } + + static IProject GetProject(IClass c) + { + if (c != null) { return (IProject)c.ProjectContent.Project; } return null; @@ -85,13 +110,18 @@ namespace ICSharpCode.UnitTesting { IMember m = GetMember(caller); if (m != null) { - return TestMethod.IsTestMethod(m); + return testFrameworks.IsTestMethod(m); } IClass c = GetClass(caller); - if (c == null || c.ProjectContent == null || c.ProjectContent.Project == null) { - return false; + if (ClassHasProject(c)) { + return testFrameworks.IsTestClass(c); } - return TestClass.IsTestClass(c); + return false; + } + + static bool ClassHasProject(IClass c) + { + return (c != null) && (c.ProjectContent.Project != null); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestAddInTree.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestAddInTree.cs new file mode 100644 index 0000000000..87ac960bf9 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestAddInTree.cs @@ -0,0 +1,21 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestAddInTree : IAddInTree + { + public List BuildItems(string path, object caller) + { + return AddInTree.BuildItems(path, caller); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestBuildOptions.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestBuildOptions.cs new file mode 100644 index 0000000000..1a2136307d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestBuildOptions.cs @@ -0,0 +1,19 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestBuildOptions : IBuildOptions + { + public bool ShowErrorListAfterBuild { + get { return BuildOptions.ShowErrorListAfterBuild; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestBuildProjectFactory.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestBuildProjectFactory.cs new file mode 100644 index 0000000000..da4a07154d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestBuildProjectFactory.cs @@ -0,0 +1,20 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestBuildProjectFactory : IBuildProjectFactory + { + public BuildProjectBeforeTestRun CreateBuildProjectBeforeTestRun(IProject project) + { + return new BuildProjectBeforeTestRun(project); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs index af5b3fec2e..d3bc62c853 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestCommands.cs @@ -27,28 +27,42 @@ namespace ICSharpCode.UnitTesting public class AddNUnitReferenceCommand : AbstractMenuCommand { - public override void Run() + public void Run(IProject project) { - if (ProjectService.CurrentProject != null) { - ProjectService.AddProjectItem(ProjectService.CurrentProject, new ReferenceProjectItem(ProjectService.CurrentProject, "nunit.framework")); - ProjectService.CurrentProject.Save(); + if (project != null) { + ReferenceProjectItem nunitRef = new ReferenceProjectItem(project, "nunit.framework"); + ProjectService.AddProjectItem(project, nunitRef); + project.Save(); } } + + public override void Run() + { + Run(ProjectService.CurrentProject); + } } public class GotoDefinitionCommand : AbstractMenuCommand { + IUnitTestFileService fileService; + + public GotoDefinitionCommand() + : this(new UnitTestFileService()) + { + } + + public GotoDefinitionCommand(IUnitTestFileService fileService) + { + this.fileService = fileService; + } + public override void Run() { ITestTreeView treeView = Owner as ITestTreeView; if (treeView != null) { - IMember member = treeView.SelectedMethod; + IMember member = GetMember(treeView); IClass c = treeView.SelectedClass; if (member != null) { - BaseTestMethod baseTestMethod = member as BaseTestMethod; - if (baseTestMethod != null) { - member = baseTestMethod.Method; - } GotoMember(member); } else if (c != null) { GotoClass(c); @@ -56,6 +70,18 @@ namespace ICSharpCode.UnitTesting } } + IMember GetMember(ITestTreeView treeView) + { + IMember member = treeView.SelectedMethod; + if (member != null) { + BaseTestMethod baseTestMethod = member as BaseTestMethod; + if (baseTestMethod != null) { + return baseTestMethod.Method; + } + } + return member; + } + void GotoMember(IMember member) { MemberResolveResult resolveResult = new MemberResolveResult(null, null, member); @@ -71,9 +97,9 @@ namespace ICSharpCode.UnitTesting void GotoFilePosition(FilePosition filePosition) { if (filePosition.Position.IsEmpty) { - FileService.OpenFile(filePosition.FileName); + fileService.OpenFile(filePosition.FileName); } else { - FileService.JumpToFilePosition(filePosition.FileName, filePosition.Line, filePosition.Column); + fileService.JumpToFilePosition(filePosition.FileName, filePosition.Line - 1, filePosition.Column - 1); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestDebuggerService.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestDebuggerService.cs new file mode 100644 index 0000000000..38fabcfe68 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestDebuggerService.cs @@ -0,0 +1,23 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Debugging; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestDebuggerService : IUnitTestDebuggerService + { + public bool IsDebuggerLoaded { + get { return DebuggerService.IsDebuggerLoaded; } + } + + public IDebugger CurrentDebugger { + get { return DebuggerService.CurrentDebugger; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestFileService.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestFileService.cs new file mode 100644 index 0000000000..21b2fc7f89 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestFileService.cs @@ -0,0 +1,25 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestFileService : IUnitTestFileService + { + public void OpenFile(string fileName) + { + FileService.OpenFile(fileName); + } + + public void JumpToFilePosition(string fileName, int line, int column) + { + FileService.JumpToFilePosition(fileName, line, column); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs new file mode 100644 index 0000000000..9f5eaeb67a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestMessageService.cs @@ -0,0 +1,20 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestMessageService : IUnitTestMessageService + { + public bool AskQuestion(string question, string caption) + { + return MessageService.AskQuestion(question, caption); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestProcessRunner.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestProcessRunner.cs new file mode 100644 index 0000000000..c8de4aeef5 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestProcessRunner.cs @@ -0,0 +1,57 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Util; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestProcessRunner : IUnitTestProcessRunner + { + ProcessRunner runner; + + public event LineReceivedEventHandler OutputLineReceived { + add { runner.OutputLineReceived += value; } + remove { runner.OutputLineReceived -= value; } + } + + public event LineReceivedEventHandler ErrorLineReceived { + add { runner.ErrorLineReceived += value; } + remove { runner.ErrorLineReceived -= value; } + } + + public event EventHandler ProcessExited { + add { runner.ProcessExited += value; } + remove { runner.ProcessExited -= value; } + } + + public UnitTestProcessRunner() + { + runner = new ProcessRunner(); + } + + public bool LogStandardOutputAndError { + get { return runner.LogStandardOutputAndError; } + set { runner.LogStandardOutputAndError = value; } + } + + public string WorkingDirectory { + get { return runner.WorkingDirectory; } + set { runner.WorkingDirectory = value; } + } + + public void Start(string command, string arguments) + { + runner.Start(command, arguments); + } + + public void Kill() + { + runner.Kill(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestSaveAllFilesCommand.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestSaveAllFilesCommand.cs new file mode 100644 index 0000000000..8725ec2008 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestSaveAllFilesCommand.cs @@ -0,0 +1,19 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestSaveAllFilesCommand : IUnitTestSaveAllFilesCommand + { + public void SaveAllFiles() + { + ICSharpCode.SharpDevelop.Commands.SaveAllFiles.SaveAll(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestTaskService.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestTaskService.cs new file mode 100644 index 0000000000..0c26e5329f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestTaskService.cs @@ -0,0 +1,39 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestTaskService : IUnitTestTaskService + { + public void ClearExceptCommentTasks() + { + TaskService.ClearExceptCommentTasks(); + } + + public bool InUpdate { + get { return TaskService.InUpdate; } + set { TaskService.InUpdate = value; } + } + + public MessageViewCategory BuildMessageViewCategory { + get { return TaskService.BuildMessageViewCategory; } + } + + public void Add(Task task) + { + TaskService.Add(task); + } + + public bool SomethingWentWrong { + get { return TaskService.SomethingWentWrong; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestWorkbench.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestWorkbench.cs new file mode 100644 index 0000000000..5a031e4bb1 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestWorkbench.cs @@ -0,0 +1,31 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.UnitTesting +{ + public class UnitTestWorkbench : IUnitTestWorkbench + { + public PadDescriptor GetPad(Type type) + { + return WorkbenchSingleton.Workbench.GetPad(type); + } + + public void SafeThreadAsyncCall(Action method) + { + WorkbenchSingleton.SafeThreadAsyncCall(method); + } + + public void SafeThreadAsyncCall(Action method, A arg1) + { + WorkbenchSingleton.SafeThreadAsyncCall(method, arg1); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs index f6e2f27ed6..465f23aebb 100644 --- a/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs +++ b/src/AddIns/Analysis/UnitTesting/Src/UnitTestsPad.cs @@ -18,7 +18,7 @@ using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.UnitTesting { - public class UnitTestsPad : AbstractPadContent + public class UnitTestsPad : AbstractPadContent, IUnitTestsPad { TestTreeView treeView; bool disposed; @@ -28,11 +28,16 @@ namespace ICSharpCode.UnitTesting static UnitTestsPad instance; public UnitTestsPad() + : this(TestService.RegisteredTestFrameworks) + { + } + + public UnitTestsPad(IRegisteredTestFrameworks testFrameworks) { instance = this; panel = new Panel(); - treeView = CreateTestTreeView(); + treeView = CreateTestTreeView(testFrameworks); treeView.Dock = DockStyle.Fill; treeView.DoubleClick += TestTreeViewDoubleClick; treeView.KeyPress += TestTreeViewKeyPress; @@ -49,7 +54,6 @@ namespace ICSharpCode.UnitTesting OnAddedLoadSolutionProjectsThreadEndedHandler(); // Display currently open solution. - if (!IsParserLoadingSolution) { Solution openSolution = GetOpenSolution(); if (openSolution != null) { @@ -68,15 +72,11 @@ namespace ICSharpCode.UnitTesting } public static UnitTestsPad Instance { - get { - return instance; - } + get { return instance; } } public override object Control { - get { - return panel; - } + get { return panel; } } public override void Dispose() @@ -97,9 +97,22 @@ namespace ICSharpCode.UnitTesting } public TestTreeView TestTreeView { - get { - return treeView; - } + get { return treeView; } + } + + public void ResetTestResults() + { + treeView.ResetTestResults(); + } + + public IProject[] GetProjects() + { + return treeView.GetProjects(); + } + + public TestProject GetTestProject(IProject project) + { + return treeView.GetTestProject(project); } /// @@ -137,15 +150,7 @@ namespace ICSharpCode.UnitTesting protected void SolutionFolderRemoved(ISolutionFolder solutionFolder) { - IProject project = solutionFolder as IProject; - if (project != null) { - treeView.RemoveProject(project); - } - - if (solutionFolder is ISolutionFolderContainer) { - // recurse into child folders that were also removed - ((ISolutionFolderContainer)solutionFolder).Folders.ForEach(SolutionFolderRemoved); - } + treeView.RemoveSolutionFolder(solutionFolder); } /// @@ -164,23 +169,12 @@ namespace ICSharpCode.UnitTesting /// protected void ProjectItemRemoved(ProjectItem projectItem) { - if (IsTestFrameworkReferenceProjectItem(projectItem)) { - if (!TestProject.IsTestProject(projectItem.Project)) { - treeView.RemoveProject(projectItem.Project); - } - } + treeView.ProjectItemRemoved(projectItem); } - /// - /// Adds the test project to the test tree view if it has - /// a reference to a unit testing framework and is not - /// already in the test tree. - /// protected void ProjectItemAdded(ProjectItem projectItem) { - if (IsTestFrameworkReferenceProjectItem(projectItem)) { - treeView.AddProject(projectItem.Project); - } + treeView.ProjectItemAdded(projectItem); } /// @@ -213,9 +207,9 @@ namespace ICSharpCode.UnitTesting /// Virtual method so we can override this method and return /// a dummy TestTreeView when testing. /// - protected virtual TestTreeView CreateTestTreeView() + protected virtual TestTreeView CreateTestTreeView(IRegisteredTestFrameworks testFrameworks) { - return new TestTreeView(); + return new TestTreeView(testFrameworks); } /// @@ -231,9 +225,7 @@ namespace ICSharpCode.UnitTesting /// solution. /// protected virtual bool IsParserLoadingSolution { - get { - return ParserService.LoadSolutionProjectsThreadRunning; - } + get { return ParserService.LoadSolutionProjectsThreadRunning; } } /// @@ -320,15 +312,6 @@ namespace ICSharpCode.UnitTesting command.Run(); } - bool IsTestFrameworkReferenceProjectItem(ProjectItem projectItem) - { - ReferenceProjectItem referenceProjectItem = projectItem as ReferenceProjectItem; - if (referenceProjectItem != null) { - return TestProject.IsTestFrameworkReference(referenceProjectItem); - } - return false; - } - void ProjectItemAdded(object source, ProjectItemEventArgs e) { ProjectItemAdded(e.ProjectItem); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/CreateNUnitTestRunnerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/CreateNUnitTestRunnerTestFixture.cs new file mode 100644 index 0000000000..23889a32fc --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/CreateNUnitTestRunnerTestFixture.cs @@ -0,0 +1,47 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class CreateNUnitTestRunnerTestFixture + { + [TestFixtureSetUp] + public void SetUpFixture() + { + if (!PropertyService.Initialized) { + PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); + } + } + + [Test] + public void NUnitTestFrameworkCreateTestRunnerReturnsNUnitTestRunner() + { + NUnitTestFramework testFramework = new NUnitTestFramework(); + Assert.IsInstanceOf(typeof(NUnitTestRunner), testFramework.CreateTestRunner()); + } + + [Test] + public void NUnitTestFrameworkCreateTestDebuggerReturnsNUnitTestDebugger() + { + NUnitTestFramework testFramework = new NUnitTestFramework(); + Assert.IsInstanceOf(typeof(NUnitTestDebugger), testFramework.CreateTestDebugger()); + } + + [Test] + public void IsBuildNeededBeforeTestRunReturnsTrue() + { + NUnitTestFramework testFramework = new NUnitTestFramework(); + Assert.IsTrue(testFramework.IsBuildNeededBeforeTestRun); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs new file mode 100644 index 0000000000..10cbede772 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleCommandLineTests.cs @@ -0,0 +1,266 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class NUnitConsoleCommandLineTests + { + CompilableProject project; + + [SetUp] + public void SetUp() + { + project = new MockCSharpProject(); + project.FileName = @"C:\Projects\MyTests\MyTests.csproj"; + project.AssemblyName = "MyTests"; + project.OutputType = OutputType.Library; + project.SetProperty("OutputPath", null); + } + + [Test] + public void TestResultsFile() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.Results = @"C:\results.txt"; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /results=\"C:\\results.txt\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void NoLogo() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = true; + app.ShadowCopy = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nologo"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void NoShadowCopy() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = false; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /noshadow"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void NoThread() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.NoThread = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nothread"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void NoDots() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.NoDots = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /nodots"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void Labels() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.Labels = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /labels"; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void TestFixture() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.Fixture = "TestFixture"; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void TestNamespace() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.NamespaceFilter = "TestFixture"; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void XmlOutputFile() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.XmlOutputFile = @"C:\NUnit.xml"; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /xml=\"C:\\NUnit.xml\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void TestMethod() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + app.Fixture = "TestFixture"; + app.Test = "Test"; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void TestMethodSpecifiedInInitialize() + { + MockClass testFixture = new MockClass("TestFixture"); + MockMethod testMethod = new MockMethod(testFixture, "Test"); + SelectedTests selectedTests = new SelectedTests(project, null, testFixture, testMethod); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"TestFixture.Test\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void TestNamespaceSpecifiedInInitialize() + { + SelectedTests selectedTests = new SelectedTests(project, "Project.MyTests", null, null); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" /run=\"Project.MyTests\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void FullCommandLine() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = true; + app.ShadowCopy = true; + + FileUtility.ApplicationRootPath = @"C:\SharpDevelop"; + + string expectedFullCommandLine = + "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + + "\"C:\\Projects\\MyTests\\MyTests.dll\" " + + "/nologo"; + Assert.AreEqual(expectedFullCommandLine, app.GetCommandLine()); + } + + /// + /// Tests that a space is appended between the items added + /// to the UnitTestApplicationStartapp.Assemblies + /// when the command line is generated. + /// + [Test] + public void SecondAssemblySpecified() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.Assemblies.Add("SecondAssembly.dll"); + app.NoLogo = false; + app.ShadowCopy = true; + app.Results = @"C:\results.txt"; + + string expectedCommandLine = + "\"C:\\Projects\\MyTests\\MyTests.dll\" " + + "\"SecondAssembly.dll\" " + + "/results=\"C:\\results.txt\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void GetProject() + { + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + Assert.AreSame(project, app.Project); + } + + [Test] + public void TestInnerClassSpecifiedInInitialize() + { + MockClass testFixture = new MockClass("MyTests.TestFixture.InnerTest", "MyTests.TestFixture+InnerTest"); + SelectedTests selectedTests = new SelectedTests(project, null, testFixture, null); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + app.NoLogo = false; + app.ShadowCopy = true; + + string expectedCommandLine = "\"C:\\Projects\\MyTests\\MyTests.dll\" " + + "/run=\"MyTests.TestFixture+InnerTest\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void XmlOutputFileNameSpecifiedOnCommandLine() + { + UnitTestingOptions options = new UnitTestingOptions(new Properties()); + options.CreateXmlOutputFile = true; + MockClass testFixture = new MockClass("MyTests.TestFixture.MyTest"); + SelectedTests selectedTests = new SelectedTests(project, null, testFixture, null); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests, options); + app.NoLogo = false; + app.ShadowCopy = true; + + string expectedCommandLine = + "\"C:\\Projects\\MyTests\\MyTests.dll\" " + + "/xml=\"C:\\Projects\\MyTests\\MyTests-TestResult.xml\" " + + "/run=\"MyTests.TestFixture.MyTest\""; + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs new file mode 100644 index 0000000000..049f9f3019 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleExeSelectedTestFixture.cs @@ -0,0 +1,100 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; +using NUnit.Framework; +using ICSharpCode.UnitTesting; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + /// + /// If the project explicitly targets 32 bit (x86) architecture then nunit-console-x86.exe should be + /// used. Otherwise the normal nunit-console.exe is used. + /// + [TestFixture] + public class NUnitConsoleExeSelectedTestFixture + { + string oldRootPath; + + [TestFixtureSetUp] + public void SetUpFixture() + { + oldRootPath = FileUtility.ApplicationRootPath; + FileUtility.ApplicationRootPath = @"D:\SharpDevelop"; + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + FileUtility.ApplicationRootPath = oldRootPath; + } + + [Test] + public void NothingSpecified() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", app.FileName); + } + + [Test] + public void TargetCpuAnyCPUDotnet2() + { + MockCSharpProject project = new MockCSharpProject(); + project.ActiveConfiguration = "Debug"; + project.ActivePlatform = "AnyCPU"; + project.SetProperty("PlatformTarget", "AnyCPU"); + project.SetProperty("TargetFrameworkVersion", "v3.5"); + + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2.exe", app.FileName); + } + + [Test] + public void NUnitConsole32BitUsedWhenTargetCpuIs32BitDotnet2() + { + MockCSharpProject project = new MockCSharpProject(); + project.ActiveConfiguration = "Debug"; + project.ActivePlatform = "AnyCPU"; + project.SetProperty("PlatformTarget", "x86"); + project.SetProperty("TargetFrameworkVersion", "v3.5"); + + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-dotnet2-x86.exe", app.FileName); + } + + [Test] + public void NUnitConsole32BitUsedWhenTargetCpuIs32Bit() + { + MockCSharpProject project = new MockCSharpProject(); + project.ActiveConfiguration = "Debug"; + project.ActivePlatform = "AnyCPU"; + project.SetProperty("PlatformTarget", "x86"); + + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe", app.FileName); + } + + [Test] + public void NotMSBuildBasedProject() + { + MissingProject project = new MissingProject(@"C:\Projects\Test.proj", "Test"); + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + + Assert.AreEqual(project.GetType().BaseType, typeof(AbstractProject), "MissingProject should be derived from AbstractProject."); + Assert.AreEqual(@"D:\SharpDevelop\bin\Tools\NUnit\nunit-console.exe", app.FileName); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs new file mode 100644 index 0000000000..b837787072 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitConsoleProcessStartInfoTestFixture.cs @@ -0,0 +1,62 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class NUnitConsoleProcessStartInfoTestFixture + { + ProcessStartInfo info; + + [TestFixtureSetUp] + public void SetUpFixture() + { + FileUtility.ApplicationRootPath = @"C:\SharpDevelop"; + } + + [SetUp] + public void Init() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests selectedTests = new SelectedTests(project); + NUnitConsoleApplication app = new NUnitConsoleApplication(selectedTests); + + info = app.GetProcessStartInfo(); + } + + [Test] + public void WorkingDirectoryIsNUnitConsoleApplicationDirectory() + { + string expectedDirectory = @"C:\SharpDevelop\bin\Tools\NUnit"; + Assert.AreEqual(expectedDirectory, info.WorkingDirectory); + } + + [Test] + public void FileNameIsNUnitConsoleExe() + { + string expectedFileName = @"C:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe"; + Assert.AreEqual(expectedFileName, info.FileName); + } + + [Test] + public void CommandLineArgumentsAreNUnitConsoleExeCommandLineArguments() + { + string expectedCommandLine = + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + + Assert.AreEqual(expectedCommandLine, info.Arguments); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs new file mode 100644 index 0000000000..cfce2eeb3b --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestClassTests.cs @@ -0,0 +1,90 @@ +// +// +// +// +// $Revision$ +// + +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class NUnitTestFrameworkIsTestClassTests + { + NUnitTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new NUnitTestFramework(); + } + + [Test] + public void IsTestClassReturnsFalseHasClassHasNoAttributes() + { + MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); + Assert.IsFalse(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsTrueHasClassHasTestFixtureAttributeMissingAttributePart() + { + MockAttribute testAttribute = new MockAttribute("TestFixture"); + MockClass mockClass = MockClass.CreateMockClassWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsTrueHasClassHasTestFixtureAttribute() + { + MockAttribute testFixtureAttribute = new MockAttribute("TestFixtureAttribute"); + MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute); + Assert.IsTrue(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsTrueHasClassHasFullyQualifiedNUnitTestFixtureAttribute() + { + MockAttribute testFixtureAttribute = new MockAttribute("NUnit.Framework.TestFixtureAttribute"); + MockClass mockClass = MockClass.CreateMockClassWithAttribute(testFixtureAttribute); + Assert.IsTrue(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsFalseWhenClassIsNull() + { + Assert.IsFalse(testFramework.IsTestClass(null)); + } + + [Test] + public void IsTestClassReturnsFalseWhenProjectContentLanguageIsNull() + { + IProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + MockClass mockClass = new MockClass(mockProjectContent); + + Assert.IsFalse(testFramework.IsTestClass(mockClass)); + } + + [Test] + public void IsTestClassReturnsFalseWhenProjectContentLanguageNameComparerIsNull() + { + IProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + mockProjectContent.Language = new LanguageProperties(null); + MockClass mockClass = new MockClass(mockProjectContent); + mockClass.Attributes.Add(new MockAttribute("Test")); + + Assert.IsFalse(testFramework.IsTestClass(mockClass)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMethodTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMethodTests.cs new file mode 100644 index 0000000000..1bebb26588 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestMethodTests.cs @@ -0,0 +1,113 @@ +// +// +// +// +// $Revision$ +// + +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class NUnitTestFrameworkIsTestMethodTests + { + NUnitTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new NUnitTestFramework(); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasNoAttributes() + { + MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeWithoutAttributePart() + { + MockAttribute testAttribute = new MockAttribute("Test"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsTrueWhenMethodHasTestAttributeAttribute() + { + MockAttribute testAttribute = new MockAttribute("TestAttribute"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsTrueWhenMethodHasFullyQualifiedNUnitTestAttribute() + { + MockAttribute testAttribute = new MockAttribute("NUnit.Framework.TestAttribute"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodIsNull() + { + Assert.IsFalse(testFramework.IsTestMethod(null)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenProjectContentLanguageHasNullNameComparer() + { + MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); + mockClass.MockProjectContent.Language = new LanguageProperties(null); + MockMethod mockMethod = new MockMethod(mockClass); + mockMethod.Attributes.Add(new MockAttribute("Test")); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + /// + /// Even if the project is null the method should be + /// flagged as a TestMethod. + /// + [Test] + public void IsTestMethodReturnsTrueWhenProjectIsNull() + { + MockAttribute testAttribute = new MockAttribute("Test"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + MockProjectContent mockProjectContent = (MockProjectContent)mockMethod.DeclaringType.ProjectContent; + mockProjectContent.Project = null; + + Assert.IsTrue(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasNullLanguage() + { + MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); + mockClass.MockProjectContent.Language = null; + MockMethod mockMethod = new MockMethod(mockClass); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + + [Test] + public void IsTestMethodReturnsFalseWhenMethodHasHasParameters() + { + MockAttribute testAttribute = new MockAttribute("Test"); + MockMethod mockMethod = MockMethod.CreateMockMethodWithAttribute(testAttribute); + MockParameter mockParameter = new MockParameter(); + mockMethod.Parameters.Add(mockParameter); + + Assert.IsFalse(testFramework.IsTestMethod(mockMethod)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestProjectTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestProjectTests.cs new file mode 100644 index 0000000000..9005dfb052 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestFrameworkIsTestProjectTests.cs @@ -0,0 +1,96 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class NUnitTestFrameworkIsTestProjectTests + { + NUnitTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new NUnitTestFramework(); + } + + [Test] + public void NUnitTestFrameworkImplementsITestFramework() + { + Assert.IsNotNull(testFramework as ITestFramework); + } + + [Test] + public void IsTestProjectReturnsFalseForNullProject() + { + Assert.IsFalse(testFramework.IsTestProject(null)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReference() + { + MockCSharpProject project = new MockCSharpProject(); + + ReferenceProjectItem systemRef = new ReferenceProjectItem(project, "System"); + ProjectService.AddProjectItem(project, systemRef); + + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "NUnit.Framework"); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsFalseForProjectWithoutNUnitFrameworkAssemblyReference() + { + MockCSharpProject project = new MockCSharpProject(); + Assert.IsFalse(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReferenceIgnoringCase() + { + MockCSharpProject project = new MockCSharpProject(); + + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "NUNIT.FRAMEWORK"); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReferenceIgnoringNonReferenceProjectItems() + { + MockCSharpProject project = new MockCSharpProject(); + + FileProjectItem fileItem = new FileProjectItem(project, ItemType.Compile, "test.cs"); + ProjectService.AddProjectItem(project, fileItem); + + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, "nunit.framework"); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForProjectWithNUnitFrameworkAssemblyReferenceUsingFullName() + { + MockCSharpProject project = new MockCSharpProject(); + string assemblyName = "nunit.framework, Version=2.5.3.9345, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77"; + ReferenceProjectItem nunitFrameworkRef = new ReferenceProjectItem(project, assemblyName); + ProjectService.AddProjectItem(project, nunitFrameworkRef); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs new file mode 100644 index 0000000000..767f4bb7e3 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/NUnitTestResultFailureTestFixture.cs @@ -0,0 +1,74 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class NUnitTestResultFailureTestFixture + { + NUnitTestResult nunitTestResult; + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyNamespace.MyTests"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "Test failed"; + testResult.StackTrace = + "Test Error : MyTest.Test\r\n" + + "at TestResultTask.Create() in c:\\projects\\SharpDevelop\\TestResultTask.cs:line 45\r\n" + + "at MyTest.Test() in c:\\myprojects\\test\\..\\test\\mytest.cs:line 28\r\n" + + ""; + nunitTestResult = new NUnitTestResult(testResult); + } + + [Test] + public void TestResultTypeIsFailure() + { + Assert.AreEqual(TestResultType.Failure, nunitTestResult.ResultType); + } + + [Test] + public void TestResultMessageIsTestFailed() + { + Assert.AreEqual("Test failed", nunitTestResult.Message); + } + + [Test] + public void StackTraceFilePositionFileNameMatchesLastFileNameInStackTrace() + { + string expectedFileName = @"c:\myprojects\test\mytest.cs"; + Assert.AreEqual(expectedFileName, nunitTestResult.StackTraceFilePosition.FileName); + } + + [Test] + public void StackTraceFilePositionLineNumberIs28WhichIsEqualToReportedNUnitErrorLine() + { + Assert.AreEqual(28, nunitTestResult.StackTraceFilePosition.Line); + } + + [Test] + public void StackTraceFilePositionColumnNumberIsOne() + { + Assert.AreEqual(1, nunitTestResult.StackTraceFilePosition.Column); + } + + [Test] + public void ChangingStackTraceToEmptyStringSetsStackTraceFilePositionToEmpty() + { + nunitTestResult.StackTraceFilePosition = new FilePosition("test.cs", 10, 2); + nunitTestResult.StackTrace = String.Empty; + Assert.IsTrue(nunitTestResult.StackTraceFilePosition.IsEmpty); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/RegisteredTestFrameworksTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/RegisteredTestFrameworksTestFixture.cs new file mode 100644 index 0000000000..5b89ee6aa2 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/RegisteredTestFrameworksTestFixture.cs @@ -0,0 +1,240 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class RegisteredTestFrameworksTestFixture + { + RegisteredTestFrameworks testFrameworks; + MockTestFramework nunitTestFramework; + MockTestFramework mbUnitTestFramework; + + [SetUp] + public void Init() + { + List descriptors = new List(); + + MockTestFrameworkFactory factory = new MockTestFrameworkFactory(); + + Properties mbUnitProperties = new Properties(); + mbUnitProperties["id"] = "mbunit"; + mbUnitProperties["class"] = "MBUnitTestFramework"; + mbUnitProperties["supportedProjects"] = ".vbproj"; + mbUnitTestFramework = new MockTestFramework(); + factory.Add("MBUnitTestFramework", mbUnitTestFramework); + + Properties nunitProperties = new Properties(); + nunitProperties["id"] = "nunit"; + nunitProperties["class"] = "NUnitTestFramework"; + nunitProperties["supportedProjects"] = ".csproj"; + nunitTestFramework = new MockTestFramework(); + factory.Add("NUnitTestFramework", nunitTestFramework); + + TestFrameworkDescriptor mbUnitDescriptor = new TestFrameworkDescriptor(mbUnitProperties, factory); + TestFrameworkDescriptor nunitDescriptor = new TestFrameworkDescriptor(nunitProperties, factory); + + descriptors.Add(mbUnitDescriptor); + descriptors.Add(nunitDescriptor); + + MockAddInTree addinTree = new MockAddInTree(); + addinTree.AddItems("/SharpDevelop/UnitTesting/TestFrameworks", descriptors); + + testFrameworks = new RegisteredTestFrameworks(addinTree); + } + + [Test] + public void NUnitTestFrameworkRegisteredForUseWithProjectsWithCSharpProjectFileExtension() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test\MyProj.csproj"; + + Assert.AreEqual(nunitTestFramework, testFrameworks.GetTestFrameworkForProject(project)); + } + + [Test] + public void MbUnitTestFrameworkRegisteredForUseWithProjectsWithVBNetProjectFileExtension() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test\MyProj.vbproj"; + + Assert.AreEqual(mbUnitTestFramework, testFrameworks.GetTestFrameworkForProject(project)); + } + + [Test] + public void IsTestMethodReturnsFalseForUnknownMbUnitFrameworkTestMethod() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.MockDeclaringType.MockProjectContent.ProjectAsIProject.FileName = @"d:\projects\test.vbproj"; + + Assert.IsFalse(testFrameworks.IsTestMethod(method)); + } + + [Test] + public void IsTestMethodReturnsTrueForKnownMbUnitFrameworkTestMethod() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.MockDeclaringType.MockProjectContent.ProjectAsIProject.FileName = @"d:\projects\test.vbproj"; + + mbUnitTestFramework.AddTestMethod(method); + + Assert.IsTrue(testFrameworks.IsTestMethod(method)); + } + + [Test] + public void IsTestMethodDoesNotThrowNullReferenceExceptionWhenNoTestFrameworkSupportsProject() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.MockDeclaringType.MockProjectContent.ProjectAsIProject.FileName = @"d:\projects\test.unknown"; + + Assert.IsFalse(testFrameworks.IsTestMethod(method)); + } + + [Test] + public void IsTestMethodDoesNotThrowNullReferenceWhenNullPassedToMethod() + { + Assert.IsFalse(testFrameworks.IsTestMethod(null)); + } + + [Test] + public void IsTestClassReturnsFalseForUnknownMbUnitFrameworkTestClass() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.MockProjectContent.ProjectAsIProject.FileName = @"d:\projects\test.vbproj"; + + Assert.IsFalse(testFrameworks.IsTestClass(c)); + } + + [Test] + public void IsTestClassReturnsTrueForKnownMbUnitFrameworkTestClass() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.MockProjectContent.ProjectAsIProject.FileName = @"d:\projects\test.vbproj"; + + mbUnitTestFramework.AddTestClass(c); + + Assert.IsTrue(testFrameworks.IsTestClass(c)); + } + + [Test] + public void IsTestClassDoesNotThrowNullReferenceExceptionWhenNoTestFrameworkSupportsProject() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.MockProjectContent.ProjectAsIProject.FileName = @"d:\projects\test.unknown"; + + Assert.IsFalse(testFrameworks.IsTestClass(c)); + } + + [Test] + public void IsTestClassDoesNotThrowNullReferenceWhenNullPassedToMethod() + { + Assert.IsFalse(testFrameworks.IsTestClass(null)); + } + + [Test] + public void IsTestProjectReturnsFalseForUnknownMbUnitFrameworkTestProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.vbproj"; + + Assert.IsFalse(testFrameworks.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueForKnownMbUnitFrameworkTestProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.vbproj"; + + mbUnitTestFramework.AddTestProject(project); + + Assert.IsTrue(testFrameworks.IsTestProject(project)); + } + + [Test] + public void IsTestProjectDoesNotThrowNullReferenceExceptionWhenNoTestFrameworkSupportsProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.unknown"; + + Assert.IsFalse(testFrameworks.IsTestProject(project)); + } + + [Test] + public void IsTestProjectDoesNotThrowNullReferenceWhenNullPassedToMethod() + { + Assert.IsFalse(testFrameworks.IsTestProject(null)); + } + + [Test] + public void CreateTestRunnerReturnsNewTestRunnerFromCorrectTestFramework() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.csproj"; + + ITestRunner testRunner = testFrameworks.CreateTestRunner(project); + ITestRunner[] expectedTestRunners = new ITestRunner[] { testRunner }; + Assert.AreEqual(expectedTestRunners, nunitTestFramework.TestRunnersCreated.ToArray()); + } + + [Test] + public void CreateTestRunnerDoesNotThrowNullRefExceptionWhenUnknownProjectPassedToCreateTestRunnerMethod() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.unknown"; + + Assert.IsNull(testFrameworks.CreateTestRunner(project)); + } + + [Test] + public void CreateTestDebuggerReturnsNewTestRunnerFromCorrectTestFramework() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.csproj"; + + ITestRunner testDebugger = testFrameworks.CreateTestDebugger(project); + ITestRunner[] expectedTestRunners = new ITestRunner[] { testDebugger }; + Assert.AreEqual(expectedTestRunners, nunitTestFramework.TestDebuggersCreated.ToArray()); + } + + [Test] + public void CreateTestDebuggerDoesNotThrowNullRefExceptionWhenUnknownProjectPassedToCreateTestRunnerMethod() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.unknown"; + + Assert.IsNull(testFrameworks.CreateTestDebugger(project)); + } + + [Test] + public void IsBuildNeededBeforeTestRunReturnsTrueWhenTestFrameworkIsBuildNeededBeforeTestRunSetToTrue() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.csproj"; + nunitTestFramework.IsBuildNeededBeforeTestRun = true; + + Assert.IsTrue(testFrameworks.IsBuildNeededBeforeTestRunForProject(project)); + } + + [Test] + public void IsBuildNeededBeforeTestRunReturnsFalseWhenTestFrameworkIsBuildNeededBeforeTestRunSetToFalse() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\test.csproj"; + nunitTestFramework.IsBuildNeededBeforeTestRun = false; + + Assert.IsFalse(testFrameworks.IsBuildNeededBeforeTestRunForProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorIgnoresProjectFileExtensionWhitespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorIgnoresProjectFileExtensionWhitespaceTestFixture.cs new file mode 100644 index 0000000000..85d90a1cb0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorIgnoresProjectFileExtensionWhitespaceTestFixture.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestFrameworkDescriptorIgnoresProjectFileExtensionWhitespaceTestFixture + { + TestFrameworkDescriptor descriptor; + + [SetUp] + public void Init() + { + MockTestFrameworkFactory factory = new MockTestFrameworkFactory(); + Properties properties = new Properties(); + properties["id"] = "nunit"; + properties["supportedProjects"] = " .csproj; .vbproj "; + + descriptor = new TestFrameworkDescriptor(properties, factory); + } + + [Test] + public void IsSupportedProjectReturnsTrueForCSharpProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.csproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + + [Test] + public void IsSupportedProjectReturnsTrueForVBNetProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.vbproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsCSharpAndVBNetProjectsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsCSharpAndVBNetProjectsTestFixture.cs new file mode 100644 index 0000000000..083075067e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsCSharpAndVBNetProjectsTestFixture.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestFrameworkDescriptorSupportsCSharpAndVBNetProjectsTestFixture + { + TestFrameworkDescriptor descriptor; + + [SetUp] + public void Init() + { + MockTestFrameworkFactory factory = new MockTestFrameworkFactory(); + Properties properties = new Properties(); + properties["id"] = "nunit"; + properties["supportedProjects"] = ".csproj;.vbproj"; + + descriptor = new TestFrameworkDescriptor(properties, factory); + } + + [Test] + public void IsSupportedProjectReturnsTrueForCSharpProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.csproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + + [Test] + public void IsSupportedProjectReturnsTrueForVBNetProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.vbproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsCSharpProjectsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsCSharpProjectsTestFixture.cs new file mode 100644 index 0000000000..2a6ee024bb --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsCSharpProjectsTestFixture.cs @@ -0,0 +1,65 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestFrameworkDescriptorSupportsCSharpProjectsTestFixture + { + TestFrameworkDescriptor descriptor; + + [SetUp] + public void Init() + { + MockTestFrameworkFactory factory = new MockTestFrameworkFactory(); + Properties properties = new Properties(); + properties["id"] = "nunit"; + properties["supportedProjects"] = ".csproj"; + + descriptor = new TestFrameworkDescriptor(properties, factory); + } + + [Test] + public void IsSupportedProjectReturnsTrueForCSharpProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.csproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + + [Test] + public void IsSupportedProjectReturnsFalseForVBNetProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.vbproj"; + + Assert.IsFalse(descriptor.IsSupportedProject(project)); + } + + [Test] + public void IsSupportedProjectReturnsFalseForNullProject() + { + Assert.IsFalse(descriptor.IsSupportedProject(null)); + } + + [Test] + public void IsSupportedProjectReturnsTrueForCSharpProjectFileExtensionInUpperCase() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.CSPROJ"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsUpperCaseProjectFileExtensionsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsUpperCaseProjectFileExtensionsTestFixture.cs new file mode 100644 index 0000000000..c00920cf8f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDescriptorSupportsUpperCaseProjectFileExtensionsTestFixture.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestFrameworkDescriptorSupportsUpperCaseProjectFileExtensionsTestFixture + { + TestFrameworkDescriptor descriptor; + + [SetUp] + public void Init() + { + MockTestFrameworkFactory factory = new MockTestFrameworkFactory(); + Properties properties = new Properties(); + properties["id"] = "nunit"; + properties["supportedProjects"] = ".CSPROJ;.VBPROJ"; + + descriptor = new TestFrameworkDescriptor(properties, factory); + } + + [Test] + public void IsSupportedProjectReturnsTrueForCSharpProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.csproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + + [Test] + public void IsSupportedProjectReturnsTrueForVBNetProject() + { + MockCSharpProject project = new MockCSharpProject(); + project.FileName = @"d:\projects\myproj.vbproj"; + + Assert.IsTrue(descriptor.IsSupportedProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDoozerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDoozerTestFixture.cs new file mode 100644 index 0000000000..1c72774635 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestFrameworkDoozerTestFixture.cs @@ -0,0 +1,77 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestFrameworkDoozerTestFixture + { + TestFrameworkDescriptor descriptor; + TestFrameworkDoozer doozer; + MockTestFramework mockTestFramework; + MockTestFrameworkFactory mockTestFrameworkFactory; + + [SetUp] + public void Init() + { + Properties properties = new Properties(); + properties["id"] = "Default"; + properties["class"] = "UnitTesting.Tests.Utils.MockTestFramework"; + Codon codon = new Codon(null, "TestFramework", properties, null); + + mockTestFrameworkFactory = new MockTestFrameworkFactory(); + mockTestFramework = new MockTestFramework(); + mockTestFrameworkFactory.Add("UnitTesting.Tests.Utils.MockTestFramework", mockTestFramework); + + doozer = new TestFrameworkDoozer(); + descriptor = doozer.BuildItem(codon, mockTestFrameworkFactory); + } + + [Test] + public void TestFrameworkDescriptorIdIsDefault() + { + Assert.AreEqual("Default", descriptor.Id); + } + + [Test] + public void TestFrameworkDoozerImplementsIDoozer() + { + Assert.IsNotNull(doozer as IDoozer); + } + + [Test] + public void TestFrameworkDoozerDoesNotHandleConditions() + { + Assert.IsFalse(doozer.HandleConditions); + } + + [Test] + public void TestFrameworkDescriptorTestFrameworkPropertyReturnsMockTestFrameworkObject() + { + Assert.IsTrue(descriptor.TestFramework is MockTestFramework); + } + + [Test] + public void TestFrameworkDescriptorTestFrameworkPropertyOnlyCreatesOneObject() + { + ITestFramework testFramework = descriptor.TestFramework; + testFramework = descriptor.TestFramework; + + List expectedClassNames = new List(); + expectedClassNames.Add("UnitTesting.Tests.Utils.MockTestFramework"); + + Assert.AreEqual(expectedClassNames, mockTestFrameworkFactory.ClassNamesPassedToCreateMethod); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestResultsReaderTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestResultsReaderTests.cs new file mode 100644 index 0000000000..8646a74cc6 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestResultsReaderTests.cs @@ -0,0 +1,251 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestResultsReaderTests + { + [Test] + public void OneTestPass() + { + string resultsText = "Name: MyTest\r\n" + + "Result: Success\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("MyTest", result.Name); + Assert.IsTrue(result.IsSuccess); + Assert.AreEqual(TestResultType.Success, result.ResultType); + } + + [Test] + public void OneTestIgnored() + { + string resultsText = "Name: MyTest\r\n" + + "Result: Ignored\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("MyTest", result.Name); + Assert.IsTrue(result.IsIgnored); + Assert.IsFalse(result.IsSuccess); + Assert.AreEqual(TestResultType.Ignored, result.ResultType); + } + + [Test] + public void OneTestPassInParts() + { + string resultsText = "Name: MyTest\r\n" + + "Result: Success\r\n"; + + TestResultsReader reader = new TestResultsReader(); + + List results = new List(); + foreach (char ch in resultsText) { + TestResult[] readResults = reader.Read(ch.ToString()); + if (readResults.Length > 0) { + foreach (TestResult readResult in readResults) { + results.Add(readResult); + } + } + } + + Assert.AreEqual(1, results.Count); + + TestResult result = results[0]; + Assert.AreEqual("MyTest", result.Name); + Assert.IsTrue(result.IsSuccess); + } + + [Test] + public void OneTestFailure() + { + string resultsText = "Name: MyTest\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("MyTest", result.Name); + Assert.IsTrue(result.IsFailure); + Assert.IsFalse(result.IsSuccess); + Assert.IsFalse(result.IsIgnored); + Assert.AreEqual(TestResultType.Failure, result.ResultType); + } + + [Test] + public void TestMessage() + { + string resultsText = "Name: Test\r\n" + + "Message: Should not be 0.\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("Test", result.Name); + Assert.AreEqual("Should not be 0.", result.Message); + Assert.IsTrue(result.IsFailure); + } + + [Test] + public void TestStackTrace() + { + string resultsText = "Name: Test\r\n" + + "StackTrace: stack trace\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("Test", result.Name); + Assert.AreEqual("stack trace", result.StackTrace); + Assert.IsTrue(result.IsFailure); + } + + [Test] + public void ResultWithNoTestName() + { + string resultsText = "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(0, results.Length); + } + + [Test] + public void MissingNameValuePairOnFirstLine() + { + string resultsText = "MissingNameValuePair\r\n" + + "Name: Test\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("Test", result.Name); + Assert.IsTrue(result.IsFailure); + } + + [Test] + public void TwoLineTestMessage() + { + string resultsText = "Name: Test\r\n" + + "Message: Should not be 0.\r\n" + + " Should be 1.\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("Test", result.Name); + Assert.AreEqual("Should not be 0.\r\nShould be 1.", result.Message); + Assert.IsTrue(result.IsFailure); + } + + [Test] + public void ThreeLineTestMessage() + { + string resultsText = "Name: Test\r\n" + + "Message: Should not be 0.\r\n" + + " Should be 1.\r\n" + + " End of message.\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(1, results.Length); + + TestResult result = results[0]; + Assert.AreEqual("Test", result.Name); + Assert.AreEqual("Should not be 0.\r\nShould be 1.\r\nEnd of message.", result.Message); + Assert.IsTrue(result.IsFailure); + } + + [Test] + public void TwoTestFailures() + { + string resultsText = "Name: MyTest1\r\n" + + "Result: Failure\r\n" + + "Name: MyTest2\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(2, results.Length); + + TestResult result1 = results[0]; + Assert.AreEqual("MyTest1", result1.Name); + Assert.IsTrue(result1.IsFailure); + + TestResult result2 = results[1]; + Assert.AreEqual("MyTest2", result2.Name); + Assert.IsTrue(result2.IsFailure); + } + + [Test] + public void TwoTestFailuresWithMultilineMessages() + { + string resultsText = "Name: MyTest1\r\n" + + "Message: FirstLine\r\n" + + " SecondLine\r\n" + + "Result: Failure\r\n" + + "Name: MyTest2\r\n" + + "Message: FirstLine\r\n" + + " SecondLine\r\n" + + " ThirdLine\r\n" + + "Result: Failure\r\n"; + + TestResultsReader reader = new TestResultsReader(); + TestResult[] results = reader.Read(resultsText); + + Assert.AreEqual(2, results.Length); + + TestResult result1 = results[0]; + Assert.AreEqual("MyTest1", result1.Name); + Assert.AreEqual("FirstLine\r\nSecondLine", result1.Message); + Assert.IsTrue(result1.IsFailure); + + TestResult result2 = results[1]; + Assert.AreEqual("MyTest2", result2.Name); + Assert.AreEqual("FirstLine\r\nSecondLine\r\nThirdLine", result2.Message); + Assert.IsTrue(result2.IsFailure); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs new file mode 100644 index 0000000000..7b3d5e8153 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidForClassNodeTestFixture.cs @@ -0,0 +1,84 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui.ClassBrowser; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestableConditionIsValidForClassNodeTestFixture + { + TestableCondition testableCondition; + MockClass classWithTestAttribute; + ClassNode classNodeForClassWithTestAttribute; + MockRegisteredTestFrameworks testFrameworks; + + [TestFixtureSetUp] + public void SetUpFixture() + { + ResourceManager.Initialize(); + } + + [SetUp] + public void Init() + { + MockAttribute testAttribute = new MockAttribute("Test"); + classWithTestAttribute = MockClass.CreateMockClassWithAttribute(testAttribute); + IProject project = classWithTestAttribute.MockProjectContent.ProjectAsIProject; + classNodeForClassWithTestAttribute = new ClassNode(project, classWithTestAttribute); + + testFrameworks = new MockRegisteredTestFrameworks(); + testFrameworks.AddTestClass(classWithTestAttribute); + + testableCondition = new TestableCondition(testFrameworks); + } + + [Test] + public void IsValidReturnsTrueForClassWithTestAttribute() + { + Assert.IsTrue(testableCondition.IsValid(classNodeForClassWithTestAttribute, null)); + } + + [Test] + public void IsValidReturnsFalseForClassWithoutAnyAttributes() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + IProject project = c.MockProjectContent.ProjectAsIProject; + ClassNode classNode = new ClassNode(project, c); + Assert.IsFalse(testableCondition.IsValid(classNode, null)); + } + + [Test] + public void TestClassPassedToRegisteredTestFrameworksIsTestClass() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + IProject project = c.MockProjectContent.ProjectAsIProject; + ClassNode classNode = new ClassNode(project, c); + testableCondition.IsValid(classNode, null); + Assert.AreEqual(c, testFrameworks.IsTestClassParameterUsed); + } + + /// + /// When class.ProjectContent.Project == null the + /// TestableCondition.IsValid should return false. + /// + [Test] + public void IsValidReturnFalseWhenProjectIsNull() + { + classWithTestAttribute.MockProjectContent.Project = null; + Assert.IsFalse(testableCondition.IsValid(classNodeForClassWithTestAttribute, null)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs new file mode 100644 index 0000000000..70778845bc --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/TestableConditionIsValidMethodTestFixture.cs @@ -0,0 +1,67 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + [TestFixture] + public class TestableConditionIsValidForMemberNodeTestFixture + { + TestableCondition testableCondition; + MockMethod methodWithTestAttribute; + MockMemberNode memberNodeForMethodWithTestAttribute; + MockRegisteredTestFrameworks testFrameworks; + + [TestFixtureSetUp] + public void SetUpFixture() + { + ResourceManager.Initialize(); + } + + [SetUp] + public void Init() + { + MockAttribute testAttribute = new MockAttribute("Test"); + methodWithTestAttribute = MockMethod.CreateMockMethodWithAttribute(testAttribute); + memberNodeForMethodWithTestAttribute = new MockMemberNode(methodWithTestAttribute); + + testFrameworks = new MockRegisteredTestFrameworks(); + testFrameworks.AddTestMethod(methodWithTestAttribute); + + testableCondition = new TestableCondition(testFrameworks); + } + + [Test] + public void IsValidReturnsTrueForMethodWithTestAttribute() + { + Assert.IsTrue(testableCondition.IsValid(memberNodeForMethodWithTestAttribute, null)); + } + + [Test] + public void IsValidReturnsFalseForMethodWithoutAnyAttributes() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + MockMemberNode memberNode = new MockMemberNode(method); + Assert.IsFalse(testableCondition.IsValid(memberNode, null)); + } + + [Test] + public void TestMethodPassedToRegisteredTestFrameworksIsTestMethod() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + MockMemberNode memberNode = new MockMemberNode(method); + testableCondition.IsValid(memberNode, null); + Assert.AreEqual(method, testFrameworks.IsTestMethodMemberParameterUsed); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs new file mode 100644 index 0000000000..fd09a02532 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsPanelTestFixture.cs @@ -0,0 +1,153 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Frameworks +{ + /// + /// Tests the UnitTestingOptionsPanel. + /// + [TestFixture] + public class UnitTestingOptionsPanelTestFixture + { + DerivedUnitTestingOptionsPanel panel; + UnitTestingOptions options; + CheckBox labelsCheckBox; + CheckBox showLogoCheckBox; + CheckBox showProgressCheckBox; + CheckBox threadCheckBox; + CheckBox shadowCopyCheckBox; + CheckBox createXmlOutputFileCheckBox; + + [SetUp] + public void SetUp() + { + Properties p = new Properties(); + options = new UnitTestingOptions(p); + options.Labels = true; + options.NoDots = false; + options.NoShadow = false; + options.NoThread = false; + options.CreateXmlOutputFile = false; + + panel = new DerivedUnitTestingOptionsPanel(options); + panel.LoadPanelContents(); + + labelsCheckBox = (CheckBox)panel.ControlDictionary["labelsCheckBox"]; + showLogoCheckBox = (CheckBox)panel.ControlDictionary["showLogoCheckBox"]; + showProgressCheckBox = (CheckBox)panel.ControlDictionary["showProgressCheckBox"]; + threadCheckBox = (CheckBox)panel.ControlDictionary["threadCheckBox"]; + shadowCopyCheckBox = (CheckBox)panel.ControlDictionary["shadowCopyCheckBox"]; + createXmlOutputFileCheckBox = (CheckBox)panel.ControlDictionary["createXmlOutputFileCheckBox"]; + } + + [TearDown] + public void TearDown() + { + panel.Dispose(); + } + + [Test] + public void SetupFromManifestStreamResourceName() + { + Assert.AreEqual("ICSharpCode.UnitTesting.Resources.UnitTestingOptionsPanel.xfrm", panel.SetupFromManifestResourceName); + } + + [Test] + public void LabelsCheckBoxIsChecked() + { + Assert.IsTrue(labelsCheckBox.Checked); + } + + [Test] + public void LabelsSettingSaved() + { + labelsCheckBox.Checked = false; + panel.StorePanelContents(); + Assert.IsFalse(options.Labels); + } + + [Test] + public void ShowLogoCheckBoxIsChecked() + { + Assert.IsTrue(showLogoCheckBox.Checked); + } + + [Test] + public void ShowLogoSettingSaved() + { + showLogoCheckBox.Checked = false; + panel.StorePanelContents(); + Assert.IsTrue(options.NoLogo); + } + + [Test] + public void ShowProgressCheckBoxIsChecked() + { + Assert.IsTrue(showProgressCheckBox.Checked); + } + + [Test] + public void ShowProgressSettingSaved() + { + showProgressCheckBox.Checked = false; + panel.StorePanelContents(); + Assert.IsTrue(options.NoDots); + } + + [Test] + public void ShadowCopyCheckBoxIsChecked() + { + Assert.IsTrue(shadowCopyCheckBox.Checked); + } + + [Test] + public void ShadowCopySettingSaved() + { + shadowCopyCheckBox.Checked = false; + panel.StorePanelContents(); + Assert.IsTrue(options.NoShadow); + } + + [Test] + public void ThreadCheckBoxIsChecked() + { + Assert.IsTrue(threadCheckBox.Checked); + } + + [Test] + public void ThreadSettingSaved() + { + threadCheckBox.Checked = false; + panel.StorePanelContents(); + Assert.IsTrue(options.NoThread); + } + + [Test] + public void CreateXmlOutputFileCheckBoxIsChecked() + { + Assert.IsFalse(createXmlOutputFileCheckBox.Checked); + } + + [Test] + public void CreateXmlOutputFileSettingSaved() + { + options.CreateXmlOutputFile = false; + createXmlOutputFileCheckBox.Checked = true; + panel.StorePanelContents(); + Assert.IsTrue(options.CreateXmlOutputFile); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsTestFixture.cs new file mode 100644 index 0000000000..e984d928c5 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Frameworks/UnitTestingOptionsTestFixture.cs @@ -0,0 +1,163 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Frameworks +{ + /// + /// Tests the UnitTestingOptions class. + /// + [TestFixture] + public class UnitTestingOptionsTestFixture + { + UnitTestingOptions defaultOptions; + Properties p; + + [SetUp] + public void Init() + { + p = new Properties(); + defaultOptions = new UnitTestingOptions(p); + } + + [Test] + public void DefaultNoShadow() + { + Assert.IsFalse(defaultOptions.NoShadow); + } + + [Test] + public void SetNoShadow() + { + defaultOptions.NoShadow = true; + Assert.IsTrue(p.Get(UnitTestingOptions.NoShadowProperty, false)); + } + + [Test] + public void NoShadowSetToTrueInProperties() + { + Properties newProperties = new Properties(); + newProperties.Set(UnitTestingOptions.NoShadowProperty, true); + UnitTestingOptions options = new UnitTestingOptions(newProperties); + + Assert.IsTrue(options.NoShadow); + } + + [Test] + public void DefaultNoThread() + { + Assert.IsFalse(defaultOptions.NoThread); + } + + [Test] + public void SetNoThread() + { + defaultOptions.NoThread = true; + Assert.IsTrue(p.Get(UnitTestingOptions.NoThreadProperty, false)); + } + + [Test] + public void NoThreadSetToTrueInProperties() + { + Properties newProperties = new Properties(); + newProperties.Set(UnitTestingOptions.NoThreadProperty, true); + UnitTestingOptions options = new UnitTestingOptions(newProperties); + + Assert.IsTrue(options.NoThread); + } + + [Test] + public void DefaultNoLogo() + { + Assert.IsFalse(defaultOptions.NoLogo); + } + + [Test] + public void SetNoLogo() + { + defaultOptions.NoLogo = true; + Assert.IsTrue(p.Get(UnitTestingOptions.NoLogoProperty, false)); + } + + [Test] + public void NoLogoSetToTrueInProperties() + { + Properties newProperties = new Properties(); + newProperties.Set(UnitTestingOptions.NoLogoProperty, true); + UnitTestingOptions options = new UnitTestingOptions(newProperties); + + Assert.IsTrue(options.NoLogo); + } + + [Test] + public void DefaultNoDots() + { + Assert.IsFalse(defaultOptions.NoDots); + } + + [Test] + public void SetNoDots() + { + defaultOptions.NoDots = true; + Assert.IsTrue(p.Get(UnitTestingOptions.NoDotsProperty, false)); + } + + [Test] + public void NoDotsSetToTrueInProperties() + { + Properties newProperties = new Properties(); + newProperties.Set(UnitTestingOptions.NoDotsProperty, true); + UnitTestingOptions options = new UnitTestingOptions(newProperties); + + Assert.IsTrue(options.NoDots); + } + + [Test] + public void DefaultLabels() + { + Assert.IsFalse(defaultOptions.Labels); + } + + [Test] + public void SetLabels() + { + defaultOptions.Labels = true; + Assert.IsTrue(p.Get(UnitTestingOptions.LabelsProperty, false)); + } + + [Test] + public void LabelsSetToTrueInProperties() + { + Properties newProperties = new Properties(); + newProperties.Set(UnitTestingOptions.LabelsProperty, true); + UnitTestingOptions options = new UnitTestingOptions(newProperties); + + Assert.IsTrue(options.Labels); + } + + [Test] + public void SetCreateXmlOutputFileProperty() + { + defaultOptions.CreateXmlOutputFile = true; + Assert.IsTrue(p.Get(UnitTestingOptions.CreateXmlOutputFileProperty, false)); + } + + [Test] + public void CreateXmlOutputFileSetToTrueInProperties() + { + Properties newProperties = new Properties(); + newProperties.Set(UnitTestingOptions.CreateXmlOutputFileProperty, true); + UnitTestingOptions options = new UnitTestingOptions(newProperties); + + Assert.IsTrue(options.CreateXmlOutputFile); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs index 3ad8a4cd0d..b66019cecc 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/AbstractBaseClassWithTestMethodsTestFixture.cs @@ -44,34 +44,31 @@ namespace UnitTesting.Tests.Project [SetUp] public void SetUp() - { + { MockProjectContent projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; // Create the base test class. - MockClass baseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.ReflectionOrCecilLayerTests"); - baseClass.ProjectContent = projectContent; - MockMethod baseMethod = new MockMethod("InheritanceTests"); + MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.ReflectionOrCecilLayerTests"); + MockMethod baseMethod = new MockMethod(baseClass, "InheritanceTests"); baseMethod.Attributes.Add(new MockAttribute("Test")); - baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); - + // Add a second method that does not have a Test attribute. - baseMethod = new MockMethod("NonTestMethod"); - baseMethod.DeclaringType = baseClass; + baseMethod = new MockMethod(baseClass, "NonTestMethod"); baseClass.Methods.Add(baseMethod); // Create the derived test class. - c = new MockClass("ICSharpCode.SharpDevelop.Tests.CecilLayerTests"); + c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.CecilLayerTests"); + c.SetDotNetName(c.FullyQualifiedName); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Set derived class's base class. - c.BaseClass = baseClass; + c.AddBaseClass(baseClass); // Create TestClass. - testClass = new TestClass(c); + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testClass = new TestClass(c, testFrameworks); } [Test] @@ -106,7 +103,7 @@ namespace UnitTesting.Tests.Project testClasses.Add(testClass); TestResult testResult = new TestResult("ICSharpCode.SharpDevelop.Tests.CecilLayerTests.InheritanceTests"); - testResult.IsFailure = true; + testResult.ResultType = TestResultType.Failure; testClasses.UpdateTestResult(testResult); Assert.AreEqual(TestResultType.Failure, testClass.Result); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs index 5afa3d3be6..7d7008321f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/BaseTestMethodTestFixture.cs @@ -31,7 +31,7 @@ namespace UnitTesting.Tests.Project public void SetUpFixture() { mockClass = new MockClass("Tests.MyTestFixture"); - mockMethod = new MockMethod("MyMethod"); + mockMethod = new MockMethod(mockClass, "MyMethod"); mockMethodRegion = new DomRegion(0, 0, 0, 10); mockMethod.Region = mockMethodRegion; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ClassRootNamespaceTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ClassRootNamespaceTests.cs index ad605c8a9e..a3763c0b4f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/ClassRootNamespaceTests.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ClassRootNamespaceTests.cs @@ -18,12 +18,19 @@ namespace UnitTesting.Tests.Project [TestFixture] public class ClassRootNamespaceTests { + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + + [SetUp] + public void Init() + { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + } + [Test] public void OneParentNamespace() { MockClass mockClass = new MockClass("TestRootNamespace.MyFixture"); - mockClass.Namespace = "TestRootNamespace"; - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); Assert.AreEqual("TestRootNamespace", testClass.RootNamespace); } @@ -31,8 +38,7 @@ namespace UnitTesting.Tests.Project public void TwoParentNamespaces() { MockClass mockClass = new MockClass("TestRootNamespace.Tests.MyFixture"); - mockClass.Namespace = "TestRootNamespace.Tests"; - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); Assert.AreEqual("TestRootNamespace", testClass.RootNamespace); } @@ -40,8 +46,7 @@ namespace UnitTesting.Tests.Project public void NoNamespace() { MockClass mockClass = new MockClass("MyFixture"); - mockClass.Namespace = String.Empty; - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); Assert.AreEqual(String.Empty, testClass.RootNamespace); } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ClassWithTwoChildNamespacesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ClassWithTwoChildNamespacesTestFixture.cs index 3a0e86cf95..9172bf80f0 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/ClassWithTwoChildNamespacesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ClassWithTwoChildNamespacesTestFixture.cs @@ -16,14 +16,16 @@ namespace UnitTesting.Tests.Project public class ClassWithTwoChildNamespacesTestsFixture { TestClass c; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); MockClass mockClass = new MockClass("UnitTesting.Tests.MyTestFixture"); - c = new TestClass(mockClass); + c = new TestClass(mockClass, testFrameworks); } - + [Test] public void FullNamespace() { diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs index c6b933d2e1..f8e383c50d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameChangedTestFixture.cs @@ -28,6 +28,7 @@ namespace UnitTesting.Tests.Project TestProject testProject; IProject project; MockProjectContent projectContent; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -41,42 +42,35 @@ namespace UnitTesting.Tests.Project // Add a test class. projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace.MyTestFixture"); + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; - c.SetCompoundClass(c); - MockMethod test1Method = new MockMethod("Test1"); - test1Method .DeclaringType = c; - test1Method .Attributes.Add(new MockAttribute("Test")); + MockMethod test1Method = new MockMethod(c, "Test1"); + test1Method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(test1Method); // Test 2 method is from a duplicate test class. - MockMethod test2Method = new MockMethod("Test2"); - test2Method.DeclaringType = c; + MockMethod test2Method = new MockMethod(c, "Test2"); test2Method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(test2Method); projectContent.Classes.Add(c); - - testProject = new TestProject(project, projectContent); + + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); // Make sure test methods are created, otherwise // the Test2 method will never be looked at due to lazy evaluation - // of test method.s + // of test method. int count = testProject.TestClasses[0].TestMethods.Count; // Change the name of the second test class. DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); oldUnit.Classes.Add(c); c.Methods.Remove(test2Method); // Remove duplicate test class method. - // Create new compilation unit with inner class that has its method renamed. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newTestClass = new MockClass("RootNamespace.MyNewTestFixture"); - newTestClass.ProjectContent = projectContent; + MockClass newTestClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newTestClass.Attributes.Add(new MockAttribute("TestFixture")); - newTestClass.SetCompoundClass(newTestClass); projectContent.Classes.Add(newTestClass); newTestClass.Methods.Add(test2Method); newUnit.Classes.Add(newTestClass); @@ -104,7 +98,7 @@ namespace UnitTesting.Tests.Project /// /// This test ensures that the existing class in the project content is used to update - /// the test methods. So the any methods from the duplicate test class are removed. + /// the test methods. So any methods from the duplicate test class are removed. /// [Test] public void OldTestClassHasOneMethod() diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs index 7591d985fb..7f6a2face5 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateClassNameTestFixture.cs @@ -26,6 +26,7 @@ namespace UnitTesting.Tests.Project TestProject testProject; IProject project; MockProjectContent projectContent; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -40,18 +41,17 @@ namespace UnitTesting.Tests.Project // Add a test class. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace.MyTestFixture"); + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class with the same name. - MockClass secondTestClass = new MockClass("RootNamespace.MyTestFixture"); - secondTestClass.ProjectContent = projectContent; + MockClass secondTestClass = new MockClass(projectContent, "RootNamespace.MyTestFixture"); secondTestClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(secondTestClass); - testProject = new TestProject(project, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); } /// diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs index 85cc157a43..8e3a14cf86 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateMethodNameTestFixture.cs @@ -23,38 +23,38 @@ namespace UnitTesting.Tests.Project public class DuplicateMethodNameTestFixture { TestClass testClass; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() - { + { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + // Add a test class. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace.MyTestFixture"); + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add first method. - MockMethod method = new MockMethod("MyTest"); + MockMethod method = new MockMethod(c, "MyTest"); method.Attributes.Add(new MockAttribute("Test")); - method.DeclaringType = c; c.Methods.Add(method); // Add duplicate method. c.Methods.Add(method); // Add a base class that has duplicate methods. - MockClass baseClass = new MockClass("RootNamespace.MyTestFixtureBase"); + MockClass baseClass = new MockClass(projectContent, "RootNamespace.MyTestFixtureBase"); baseClass.Attributes.Add(new MockAttribute("TestFixture")); - baseClass.ProjectContent = projectContent; projectContent.Classes.Add(baseClass); - c.BaseClass = baseClass; + c.AddBaseClass(baseClass); baseClass.Methods.Add(method); baseClass.Methods.Add(method); // Create test class. - testClass = new TestClass(c); + testClass = new TestClass(c, testFrameworks); } /// diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs index 15c2a1b57e..3857a467bd 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/DuplicateProjectRootNamespaceTestFixture.cs @@ -22,7 +22,8 @@ namespace UnitTesting.Tests.Project public class DuplicateProjectRootNamespaceTestFixture { TestProject testProject; - + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + [SetUp] public void Init() { @@ -36,20 +37,16 @@ namespace UnitTesting.Tests.Project // Add a test class with a TestFixture attributes. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace.MyTestFixture"); - c.Namespace = "RootNamespace"; + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class the same root namespace. - c = new MockClass("RootNamespace.MyTestFixture2"); - c.Namespace = "RootNamespace"; + c = new MockClass(projectContent, "RootNamespace.MyTestFixture2"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); - - testProject = new TestProject(project, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs index 8874bebb3e..a9bb7eb2a5 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyProjectTestFixture.cs @@ -22,7 +22,8 @@ namespace UnitTesting.Tests.Project { TestProject testProject; MockProjectContent projectContent; - + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + [SetUp] public void Init() { @@ -36,7 +37,8 @@ namespace UnitTesting.Tests.Project projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - testProject = new TestProject(project, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); } /// @@ -45,13 +47,11 @@ namespace UnitTesting.Tests.Project /// [Test] public void NewClassInParserInfo() - { + { // Create new compilation unit with extra class. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture"); + MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newClass.Attributes.Add(new MockAttribute("TestFixture")); - newClass.ProjectContent = projectContent; - newClass.SetCompoundClass(newClass); newUnit.Classes.Add(newClass); // Update TestProject's parse info. @@ -71,20 +71,16 @@ namespace UnitTesting.Tests.Project // Create an old compilation unit with the test class // but without a [TestFixture] attribute. DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture"); - newClass.ProjectContent = projectContent; - newClass.SetCompoundClass(newClass); + MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); oldUnit.Classes.Add(newClass); - + // Create a new compilation unit with the test class // having a [TestFixture] attribute. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - newClass = new MockClass("RootNamespace.MyNewTestFixture"); + newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newClass.Attributes.Add(new MockAttribute("TestFixture")); - newClass.ProjectContent = projectContent; - newClass.SetCompoundClass(newClass); newUnit.Classes.Add(newClass); - + // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); @@ -106,20 +102,16 @@ namespace UnitTesting.Tests.Project // Create an old compilation unit with the test class // having a [TestFixture] attribute. DefaultCompilationUnit oldUnit = new DefaultCompilationUnit(projectContent); - MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture"); + MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newClass.Attributes.Add(new MockAttribute("TestFixture")); - newClass.ProjectContent = projectContent; - newClass.SetCompoundClass(newClass); oldUnit.Classes.Add(newClass); - + // Create a new compilation unit with the test class // but without a [TestFixture] attribute. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - newClass = new MockClass("RootNamespace.MyNewTestFixture"); - newClass.ProjectContent = projectContent; - newClass.SetCompoundClass(newClass); + newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newUnit.Classes.Add(newClass); - + // Update TestProject's parse info. testProject.UpdateParseInfo(oldUnit, newUnit); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs index cbf59f9613..b4896d6d2f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/EmptyRootNamespaceTestFixture.cs @@ -22,7 +22,8 @@ namespace UnitTesting.Tests.Project public class EmptyRootNamespaceTestFixture { TestProject testProject; - + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + [SetUp] public void Init() { @@ -36,20 +37,17 @@ namespace UnitTesting.Tests.Project // Add a test class with a TestFixture attributes. MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace.MyTestFixture"); - c.Namespace = "RootNamespace"; + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class no root namespace. - c = new MockClass("MyTestFixture2"); - c.Namespace = String.Empty; + c = new MockClass(projectContent, "MyTestFixture2"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); - - testProject = new TestProject(project, projectContent); + + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs index 92a772e053..efc8408d45 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassMethodRenamedTestFixture.cs @@ -31,23 +31,18 @@ namespace UnitTesting.Tests.Project // Create new compilation unit with inner class that has its method renamed. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newOuterClass = new MockClass("MyTests.A"); - newOuterClass.ProjectContent = projectContent; + MockClass newOuterClass = new MockClass(projectContent, "MyTests.A"); projectContent.Classes.Add(newOuterClass); - newOuterClass.SetCompoundClass(newOuterClass); newUnit.Classes.Add(newOuterClass); // Create the inner test class. - MockClass newInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest"); + MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", outerClass); + newInnerClass.SetDotNetName("MyTests.A+InnerATest"); newInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - newInnerClass.ProjectContent = projectContent; - newInnerClass.DeclaringType = outerClass; // Declaring type is outer class. - newInnerClass.SetCompoundClass(newInnerClass); newOuterClass.InnerClasses.Add(newInnerClass); - MockMethod method = new MockMethod("FooBarRenamed"); + MockMethod method = new MockMethod(newInnerClass, "FooBarRenamed"); method.Attributes.Add(new MockAttribute("Test")); - method.DeclaringType = newInnerClass; newInnerClass.Methods.Add(method); outerClass.InnerClasses.Add(newInnerClass); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs index fe25ec2d67..3152aa26a0 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassNameChangesTestFixture.cs @@ -30,18 +30,14 @@ namespace UnitTesting.Tests.Project // Create new compilation unit with extra class. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newOuterClass = new MockClass("MyTests.A"); - newOuterClass.ProjectContent = projectContent; + MockClass newOuterClass = new MockClass(projectContent, "MyTests.A"); projectContent.Classes.Add(newOuterClass); - newOuterClass.SetCompoundClass(newOuterClass); newUnit.Classes.Add(newOuterClass); // Create the inner test class. // Note the use of the DotNetName "MyTests.A+InnerTest". - MockClass newInnerClass = new MockClass("MyTests.A.InnerATestMod", "MyTests.A+InnerATestMod"); + MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATestMod", "MyTests.A+InnerATestMod", outerClass); newInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - newInnerClass.ProjectContent = projectContent; - newInnerClass.DeclaringType = outerClass; // Declaring type is outer class. newOuterClass.InnerClasses.Add(newInnerClass); // Update TestProject's parse info. diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs index fbb6d94d95..49114fef8f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureAttributeRemovedTestFixture.cs @@ -29,17 +29,12 @@ namespace UnitTesting.Tests.Project // Create new compilation unit with inner class that no longer has the TestFixture attribute. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); - MockClass newOuterClass = new MockClass("MyTests.A"); - newOuterClass.ProjectContent = projectContent; + MockClass newOuterClass = new MockClass(projectContent, "MyTests.A"); projectContent.Classes.Add(newOuterClass); - newOuterClass.SetCompoundClass(newOuterClass); newUnit.Classes.Add(newOuterClass); // Create the inner test class. - MockClass newInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest"); - newInnerClass.ProjectContent = projectContent; - newInnerClass.DeclaringType = outerClass; // Declaring type is outer class. - newInnerClass.SetCompoundClass(newInnerClass); + MockClass newInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); newOuterClass.InnerClasses.Add(newInnerClass); // Update TestProject's parse info. diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs index ea82c73f54..e4dd7db76e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/InnerClassTestFixtureBase.cs @@ -23,6 +23,7 @@ namespace UnitTesting.Tests.Project protected TestProject testProject; protected MockProjectContent projectContent; protected MockClass outerClass; + protected MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; protected void InitBase() { @@ -30,38 +31,31 @@ namespace UnitTesting.Tests.Project projectContent.Language = LanguageProperties.None; // Create the base test class. - outerClass = new MockClass("MyTests.A"); - outerClass.ProjectContent = projectContent; + outerClass = new MockClass(projectContent, "MyTests.A"); projectContent.Classes.Add(outerClass); // Create the inner test class. // Note the use of the DotNetName "MyTests.A+InnerTest". - innerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest"); + innerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); innerClass.Attributes.Add(new MockAttribute("TestFixture")); - innerClass.ProjectContent = projectContent; - innerClass.DeclaringType = outerClass; // Declaring type is outer class. - MockMethod method = new MockMethod("FooBar"); + MockMethod method = new MockMethod(innerClass, "FooBar"); method.Attributes.Add(new MockAttribute("Test")); - method.DeclaringType = innerClass; innerClass.Methods.Add(method); outerClass.InnerClasses.Add(innerClass); // Add another inner class that is not a test class. - MockClass nonTestInnerClass = new MockClass("MyTests.A.InnerBClass"); - nonTestInnerClass.ProjectContent = projectContent; - nonTestInnerClass.DeclaringType = outerClass; // Declaring type is outer class. + MockClass nonTestInnerClass = new MockClass(projectContent, "MyTests.A.InnerBClass", outerClass); outerClass.InnerClasses.Add(nonTestInnerClass); // Add another inner class with the same name as the InnerATest. // This makes sure duplicate classes are not added. - MockClass duplicateInnerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest"); + MockClass duplicateInnerClass = new MockClass(projectContent, "MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); duplicateInnerClass.Attributes.Add(new MockAttribute("TestFixture")); - duplicateInnerClass.ProjectContent = projectContent; - duplicateInnerClass.DeclaringType = outerClass; // Declaring type is outer class. outerClass.InnerClasses.Add(duplicateInnerClass); - testProject = new TestProject(null, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(null, projectContent, testFrameworks); if (testProject.TestClasses.Count > 0) { testClass = testProject.TestClasses[0]; } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs index 236b7a1266..b62c6903c3 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/OverriddenBaseTestMethodTestFixture.cs @@ -18,49 +18,46 @@ namespace UnitTesting.Tests.Project { TestClass testClass; MockClass c; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() - { + { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; // Create the base test class. - MockClass baseClass = new MockClass("ICSharpCode.Tests.BaseClass"); - baseClass.ProjectContent = projectContent; - + MockClass baseClass = new MockClass(projectContent, "ICSharpCode.Tests.BaseClass"); + // Add a virtual method to base class. - MockMethod baseMethod = new MockMethod("VirtualTestMethod"); + MockMethod baseMethod = new MockMethod(baseClass, "VirtualTestMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); - baseMethod.DeclaringType = baseClass; - baseMethod.IsVirtual = true; + baseMethod.Modifiers = ModifierEnum.Virtual; baseClass.Methods.Add(baseMethod); - + // Add a second method that is virtual but will not be overriden. - baseMethod = new MockMethod("VirtualNonOverriddenTestMethod"); + baseMethod = new MockMethod(baseClass, "VirtualNonOverriddenTestMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); - baseMethod.DeclaringType = baseClass; - baseMethod.IsVirtual = true; + baseMethod.Modifiers = ModifierEnum.Virtual; baseClass.Methods.Add(baseMethod); // Create the derived test class. - c = new MockClass("ICSharpCode.Tests.DerivedClass"); + c = new MockClass(projectContent, "ICSharpCode.Tests.DerivedClass"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); - + // Create a new test method that overrides one of the base class methods. - MockMethod method = new MockMethod("VirtualTestMethod"); + MockMethod method = new MockMethod(c, "VirtualTestMethod"); method.Attributes.Add(new MockAttribute("Test")); - method.DeclaringType = c; - method.IsOverride = true; + method.Modifiers = ModifierEnum.Override; c.Methods.Add(method); - + // Set derived class's base class. - c.BaseClass = baseClass; + c.AddBaseClass(baseClass); // Create TestClass. - testClass = new TestClass(c); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testClass = new TestClass(c, testFrameworks); } [Test] diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs index c616251244..fc4b3f2bf7 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/RemovedClassesTestFixture.cs @@ -29,7 +29,7 @@ namespace UnitTesting.Tests.Project myClass = new MockClass("MyTests.MyClass"); innerClass = new MockClass("MyTests.MyClass.InnerClass", "MyTests.MyClass+InnerClass"); myClass.InnerClasses.Add(innerClass); - + anotherClass = new MockClass("MyTests.AnotherClass"); List classes = new List(); @@ -42,7 +42,7 @@ namespace UnitTesting.Tests.Project [Test] public void InnerClassesIncludedInMissingClasses() - { + { List expectedClasses = new List(); expectedClasses.Add(myClass); expectedClasses.Add(innerClass); @@ -50,7 +50,7 @@ namespace UnitTesting.Tests.Project AssertContains(expectedClasses, removedClasses.GetMissingClasses()); } - + /// /// Should remove inner class too. /// @@ -64,7 +64,7 @@ namespace UnitTesting.Tests.Project AssertContains(expectedClasses, removedClasses.GetMissingClasses()); } - + [Test] public void RemoveInnerClass() { @@ -97,7 +97,7 @@ namespace UnitTesting.Tests.Project Assert.IsTrue(actualClasses.Contains(c), "Class missing: " + c.FullyQualifiedName + " Actual:\r\n" + GetClassNames(actualClasses)); } Assert.AreEqual(expectedClasses.Count, actualClasses.Count, "Actual:\r\n" + GetClassNames(actualClasses)); - } + } string GetClassNames(IList classes) { diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs new file mode 100644 index 0000000000..36854fcbe4 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassIsTestMethodUsesTestFrameworksTestFixture.cs @@ -0,0 +1,62 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Project +{ + [TestFixture] + public class TestClassIsTestMethodUsesTestFrameworksTestFixture + { + TestClass testClass; + MockClass mockTestClass; + MockMethod testMethod; + MockRegisteredTestFrameworks testFrameworks; + MockClass mockBaseTestClass; + MockMethod baseClassTestMethod; + + [SetUp] + public void Init() + { + mockTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); + mockTestClass.FullyQualifiedName = "DerivedClass"; + + testMethod = new MockMethod(mockTestClass, "myTestMethod"); + mockTestClass.Methods.Add(testMethod); + baseClassTestMethod = new MockMethod(mockTestClass, "myBaseTestMethod"); + + testFrameworks = new MockRegisteredTestFrameworks(); + testFrameworks.AddTestMethod(testMethod); + testFrameworks.AddTestMethod(baseClassTestMethod); + + mockBaseTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); + mockBaseTestClass.FullyQualifiedName = "BaseClass"; + mockBaseTestClass.Methods.Add(baseClassTestMethod); + + mockTestClass.AddBaseClass(mockBaseTestClass); + + testClass = new TestClass(mockTestClass, testFrameworks); + } + + [Test] + public void TestClassHasTestMethod() + { + Assert.AreEqual(testMethod, testClass.TestMethods[0].Method); + } + + [Test] + public void TestClassHasBaseClassTestMethod() + { + BaseTestMethod baseTestMethod = testClass.TestMethods[1].Method as BaseTestMethod; + Assert.AreEqual(baseClassTestMethod, baseTestMethod.Method); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs index b8d8492692..c6075411f3 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithOneMethodTestFixture.cs @@ -24,6 +24,7 @@ namespace UnitTesting.Tests.Project TestMethod testMethod; bool resultChangedCalled; MockProjectContent projectContent; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -34,23 +35,21 @@ namespace UnitTesting.Tests.Project ReferenceProjectItem nunitFrameworkReferenceItem = new ReferenceProjectItem(project); nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); - + projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); - mockClass.Namespace = "RootNamespace.Tests"; - mockClass.ProjectContent = projectContent; + MockClass mockClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture"); mockClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(mockClass); // Add a method to the test class - MockMethod mockMethod = new MockMethod("TestMethod"); - mockMethod.DeclaringType = mockClass; + MockMethod mockMethod = new MockMethod(mockClass, "TestMethod"); mockMethod.Attributes.Add(new MockAttribute("Test")); mockClass.Methods.Add(mockMethod); - testProject = new TestProject(project, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); testClass = testProject.TestClasses[0]; testMethod = testClass.TestMethods[0]; } @@ -71,7 +70,7 @@ namespace UnitTesting.Tests.Project public void TestFailed() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); @@ -89,7 +88,7 @@ namespace UnitTesting.Tests.Project public void TestClassIgnored() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod"); - result.IsIgnored = true; + result.ResultType = TestResultType.Ignored; testProject.UpdateTestResult(result); @@ -102,7 +101,7 @@ namespace UnitTesting.Tests.Project try { testMethod.ResultChanged += ResultChanged; TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); } finally { testMethod.ResultChanged -= ResultChanged; @@ -117,7 +116,7 @@ namespace UnitTesting.Tests.Project try { testClass.ResultChanged += ResultChanged; TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); } finally { testClass.ResultChanged -= ResultChanged; @@ -130,7 +129,7 @@ namespace UnitTesting.Tests.Project public void UpdateProjectWithTestResultHavingClassNameOnly() { TestResult result = new TestResult("ClassNameOnly"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); } @@ -139,7 +138,7 @@ namespace UnitTesting.Tests.Project public void UpdateProjectWithTestResultWithUnknownClassName() { TestResult result = new TestResult("RootNamespace.Tests.UnknownClassName.TestMethod"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); } @@ -148,7 +147,7 @@ namespace UnitTesting.Tests.Project public void UpdateProjectWithTestResultWithUnknownMethodName() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.UnknownMethodName"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); } @@ -190,10 +189,9 @@ namespace UnitTesting.Tests.Project // Create new compilation unit. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); newUnit.Classes.Add(testClass.Class); - + // Add a new method to a new compound class. - MockClass compoundClass = new MockClass("RootNamespace.MyTestFixture"); - compoundClass.ProjectContent = projectContent; + MockClass compoundClass = new MockClass(projectContent, "RootNamespace.MyTestFixture"); compoundClass.Attributes.Add(new MockAttribute("TestFixture")); MockClass mockClass = (MockClass)testClass.Class; mockClass.SetCompoundClass(compoundClass); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs index 1c8d197529..2a94cbdd2f 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestClassWithTwoMethodsTestFixture.cs @@ -23,6 +23,7 @@ namespace UnitTesting.Tests.Project TestMethod testMethod1; TestMethod testMethod2; MockClass mockClass; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -36,24 +37,21 @@ namespace UnitTesting.Tests.Project MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); - mockClass.Namespace = "RootNamespace.Tests"; - mockClass.ProjectContent = projectContent; + mockClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture"); mockClass.Attributes.Add(new MockAttribute("TestFixture")); projectContent.Classes.Add(mockClass); // Add a method to the test class - MockMethod mockMethod = new MockMethod("TestMethod1"); - mockMethod.DeclaringType = mockClass; + MockMethod mockMethod = new MockMethod(mockClass, "TestMethod1"); mockMethod.Attributes.Add(new MockAttribute("Test")); mockClass.Methods.Add(mockMethod); - mockMethod = new MockMethod("TestMethod2"); - mockMethod.DeclaringType = mockClass; + mockMethod = new MockMethod(mockClass, "TestMethod2"); mockMethod.Attributes.Add(new MockAttribute("Test")); mockClass.Methods.Add(mockMethod); - testProject = new TestProject(project, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); testClass = testProject.TestClasses[0]; testMethod1 = testClass.TestMethods[0]; testMethod2 = testClass.TestMethods[1]; @@ -69,7 +67,7 @@ namespace UnitTesting.Tests.Project public void TestMethod1Failed() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod1"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; testProject.UpdateTestResult(result); @@ -80,7 +78,7 @@ namespace UnitTesting.Tests.Project public void TestMethod1Ignored() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod1"); - result.IsIgnored = true; + result.ResultType = TestResultType.Ignored; testProject.UpdateTestResult(result); @@ -99,7 +97,7 @@ namespace UnitTesting.Tests.Project public void TestMethod1Passes() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod1"); - result.IsSuccess = true; + result.ResultType = TestResultType.Success; testProject.UpdateTestResult(result); @@ -118,7 +116,7 @@ namespace UnitTesting.Tests.Project public void TestMethod2Passes() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.TestMethod2"); - result.IsSuccess = true; + result.ResultType = TestResultType.Success; testProject.UpdateTestResult(result); @@ -192,10 +190,8 @@ namespace UnitTesting.Tests.Project [Test] public void TestMethodShouldBeUpdatedInClass() { - MockMethod mockMethod = new MockMethod("TestMethod1"); - mockMethod.DeclaringType = mockClass; + MockMethod mockMethod = new MockMethod(mockClass, "TestMethod1"); mockMethod.Attributes.Add(new MockAttribute("Test")); - mockClass.SetCompoundClass(mockClass); // Remove the existing TestMethod1 in the class. mockClass.Methods.RemoveAt(0); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs index 28fbe985e3..cb15cf0d97 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestMethodsInBaseClassTestFixture.cs @@ -39,37 +39,34 @@ namespace UnitTesting.Tests.Project { TestClass testClass; MockClass c; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() - { + { MockProjectContent projectContent = new MockProjectContent(); - projectContent.Language = LanguageProperties.None; // Create the base test class. - MockClass baseClass = new MockClass("RootNamespace.TestFixtureBase"); + MockClass baseClass = new MockClass(projectContent, "RootNamespace.TestFixtureBase"); baseClass.Attributes.Add(new MockAttribute("TestFixture")); - baseClass.ProjectContent = projectContent; - MockMethod baseMethod = new MockMethod("BaseMethod"); + MockMethod baseMethod = new MockMethod(baseClass, "BaseMethod"); baseMethod.Attributes.Add(new MockAttribute("Test")); - baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); // Create the derived test class. - c = new MockClass("RootNamespace.MyTestFixture"); + c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; - MockMethod method = new MockMethod("DerivedMethod"); - method.DeclaringType = c; + MockMethod method = new MockMethod(c, "DerivedMethod"); method.Attributes.Add(new MockAttribute("Test")); c.Methods.Add(method); projectContent.Classes.Add(c); // Set derived class's base class. - c.BaseClass = baseClass; + c.AddBaseClass(baseClass); // Create TestClass. - testClass = new TestClass(c); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testClass = new TestClass(c, testFrameworks); } [Test] @@ -110,7 +107,7 @@ namespace UnitTesting.Tests.Project testClasses.Add(testClass); TestResult testResult = new TestResult("RootNamespace.MyTestFixture.TestFixtureBase.BaseMethod"); - testResult.IsFailure = true; + testResult.ResultType = TestResultType.Failure; testClasses.UpdateTestResult(testResult); Assert.AreEqual(TestResultType.Failure, testClass.Result); @@ -123,7 +120,7 @@ namespace UnitTesting.Tests.Project testClasses.Add(testClass); TestResult testResult = new TestResult("RootNamespace.MyTestFixture.BaseMethod"); - testResult.IsFailure = true; + testResult.ResultType = TestResultType.Failure; testClasses.UpdateTestResult(testResult); Assert.AreEqual(TestResultType.Failure, testClass.Result); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs new file mode 100644 index 0000000000..1768a6e098 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectUsesTestFrameworksTestFixture.cs @@ -0,0 +1,90 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Project +{ + [TestFixture] + public class TestProjectUsesTestFrameworksTestFixture + { + MockRegisteredTestFrameworks testFrameworks; + TestProject testProject; + MockClass myTestClass; + DefaultCompilationUnit oldUnit; + + [SetUp] + public void Init() + { + testFrameworks = new MockRegisteredTestFrameworks(); + myTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); + myTestClass.SetDotNetName("MyTests"); + testFrameworks.AddTestClass(myTestClass); + + oldUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); + oldUnit.Classes.Add(myTestClass); + + testProject = new TestProject(myTestClass.Project, myTestClass.ProjectContent, testFrameworks); + } + + [Test] + public void TestProjectHasTestClassCalledMyTests() + { + Assert.AreEqual(myTestClass, testProject.TestClasses[0].Class); + } + + [Test] + public void NewTestClassInNewCompilationUnitAddedToTestProjectTestClasses() + { + MockClass myNewTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); + myNewTestClass.SetDotNetName("MyNewTests"); + testFrameworks.AddTestClass(myNewTestClass); + + DefaultCompilationUnit newUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); + newUnit.Classes.Add(myTestClass); + newUnit.Classes.Add(myNewTestClass); + + testProject.UpdateParseInfo(oldUnit, newUnit); + + Assert.AreEqual(myNewTestClass, testProject.TestClasses[1].Class); + } + + [Test] + public void NewInnerTestClassInNewCompilationUnitAddedToTestProjectTestClasses() + { + MockClass myNewInnerTestClass = MockClass.CreateMockClassWithoutAnyAttributes(); + myNewInnerTestClass.SetDotNetName("MyNewInnerTests"); + testFrameworks.AddTestClass(myNewInnerTestClass); + myTestClass.InnerClasses.Add(myNewInnerTestClass); + + DefaultCompilationUnit newUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); + newUnit.Classes.Add(myTestClass); + + testProject.UpdateParseInfo(oldUnit, newUnit); + + Assert.AreEqual(myNewInnerTestClass, testProject.TestClasses[1].Class); + } + + [Test] + public void TestProjectRemovesTestClassWhenItIsNoLongerATestClass() + { + testFrameworks.RemoveTestClass(myTestClass); + + DefaultCompilationUnit newUnit = new DefaultCompilationUnit(myTestClass.ProjectContent); + newUnit.Classes.Add(myTestClass); + + testProject.UpdateParseInfo(oldUnit, newUnit); + + Assert.AreEqual(0, testProject.TestClasses.Count); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs index 96166cd19b..85e14197f3 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TestProjectWithOneClassTestFixture.cs @@ -28,6 +28,7 @@ namespace UnitTesting.Tests.Project MockProjectContent projectContent; List classesAdded; List classesRemoved; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -46,21 +47,20 @@ namespace UnitTesting.Tests.Project // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace.MyTestFixture"); + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.SetCompoundClass(c); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class that has no test fixture attribute. - MockClass nonTestClass = new MockClass(); - nonTestClass.ProjectContent = projectContent; + MockClass nonTestClass = new MockClass(projectContent); projectContent.Classes.Add(nonTestClass); - testProject = new TestProject(project, projectContent); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); testProject.TestClasses.TestClassAdded += TestClassAdded; testProject.TestClasses.TestClassRemoved += TestClassRemoved; - + testClass = testProject.TestClasses[0]; } @@ -141,9 +141,8 @@ namespace UnitTesting.Tests.Project // Create new compilation unit with extra class. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); newUnit.Classes.Add(testClass.Class); - MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture"); + MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newClass.Attributes.Add(new MockAttribute("TestFixture")); - newClass.ProjectContent = projectContent; newClass.SetCompoundClass(newClass); newUnit.Classes.Add(newClass); @@ -173,9 +172,8 @@ namespace UnitTesting.Tests.Project // already exists in the project. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); newUnit.Classes.Add(testClass.Class); - MockClass c = new MockClass("RootNamespace.MyTestFixture"); + MockClass c = new MockClass(projectContent, "RootNamespace.MyTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; c.SetCompoundClass(c); newUnit.Classes.Add(c); @@ -202,8 +200,7 @@ namespace UnitTesting.Tests.Project // Create new compilation unit with extra class. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); newUnit.Classes.Add(testClass.Class); - MockClass newClass = new MockClass("RootNamespace.MyNewTestFixture"); - newClass.ProjectContent = projectContent; + MockClass newClass = new MockClass(projectContent, "RootNamespace.MyNewTestFixture"); newClass.SetCompoundClass(newClass); newUnit.Classes.Add(newClass); @@ -270,13 +267,11 @@ namespace UnitTesting.Tests.Project // Create new compilation unit. DefaultCompilationUnit newUnit = new DefaultCompilationUnit(projectContent); newUnit.Classes.Add(testClass.Class); - + // Add a new method to a new compound class. - MockClass compoundClass = new MockClass("RootNamespace.MyTestFixture"); - compoundClass.ProjectContent = projectContent; + MockClass compoundClass = new MockClass(projectContent, "RootNamespace.MyTestFixture"); compoundClass.Attributes.Add(new MockAttribute("TestFixture")); - MockMethod method = new MockMethod("NewMethod"); - method.DeclaringType = testClass.Class; + MockMethod method = new MockMethod(testClass.Class, "NewMethod"); method.Attributes.Add(new MockAttribute("Test")); compoundClass.Methods.Add(method); MockClass mockClass = (MockClass)testClass.Class; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs index 803aef5475..9625d1f69d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestClassesTestResultsTestFixture.cs @@ -23,26 +23,29 @@ namespace UnitTesting.Tests.Project TestClass testClass3; TestClassCollection testClasses; bool testClassesResultChanged; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testClassesResultChanged = false; testClasses = new TestClassCollection(); // TestClass1. MockClass mockClass = new MockClass("TestClass1"); - testClass1 = new TestClass(mockClass); + testClass1 = new TestClass(mockClass, testFrameworks); testClasses.Add(testClass1); // TestClass2. mockClass = new MockClass("TestClass2"); - testClass2 = new TestClass(mockClass); + testClass2 = new TestClass(mockClass, testFrameworks); testClasses.Add(testClass2); // TestClass3. mockClass = new MockClass("TestClass3"); - testClass3 = new TestClass(mockClass); + testClass3 = new TestClass(mockClass, testFrameworks); testClasses.Add(testClass3); testClasses.ResultChanged += TestClassesResultChanged; @@ -149,7 +152,7 @@ namespace UnitTesting.Tests.Project AllTestClassesPass(); MockClass mockClass = new MockClass("TestClass4"); - TestClass testClass4 = new TestClass(mockClass); + TestClass testClass4 = new TestClass(mockClass, testFrameworks); testClass4.Result = TestResultType.Failure; testClasses.Add(testClass4); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs index 6e0d8e0695..588b1419a8 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/ThreeTestMethodsTestResultsTestFixture.cs @@ -31,17 +31,18 @@ namespace UnitTesting.Tests.Project testMethods = new TestMethodCollection(); // TestMethod1. - MockMethod mockMethod = new MockMethod("TestMethod1"); + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + MockMethod mockMethod = new MockMethod(c, "TestMethod1"); testMethod1 = new TestMethod(mockMethod); testMethods.Add(testMethod1); // TestMethod2. - mockMethod = new MockMethod("TestMethod2"); + mockMethod = new MockMethod(c, "TestMethod2"); testMethod2 = new TestMethod(mockMethod); testMethods.Add(testMethod2); // TestMethod3. - mockMethod = new MockMethod("TestMethod3"); + mockMethod = new MockMethod(c, "TestMethod3"); testMethod3 = new TestMethod(mockMethod); testMethods.Add(testMethod3); @@ -157,7 +158,8 @@ namespace UnitTesting.Tests.Project { AllTestMethodsPass(); - MockMethod mockMethod = new MockMethod("TestMethod4"); + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + MockMethod mockMethod = new MockMethod(c, "TestMethod4"); TestMethod testMethod4 = new TestMethod(mockMethod); testMethod4.Result = TestResultType.Failure; testMethods.Add(testMethod4); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs index 9e5a989513..2f73f4170c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoBaseClassesWithTestMethodsTestFixture.cs @@ -26,41 +26,38 @@ namespace UnitTesting.Tests.Project { TestClass testClass; MockClass c; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() - { + { MockProjectContent projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - + // Create the top base test class. - MockClass baseBaseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture"); - baseBaseClass.ProjectContent = projectContent; - MockMethod baseMethod = new MockMethod("BaseBaseTest"); + MockClass baseBaseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseBaseTestFixture"); + MockMethod baseMethod = new MockMethod(baseBaseClass, "BaseBaseTest"); baseMethod.Attributes.Add(new MockAttribute("Test")); - baseMethod.DeclaringType = baseBaseClass; baseBaseClass.Methods.Add(baseMethod); // Create the next level test class. - MockClass baseClass = new MockClass("ICSharpCode.SharpDevelop.Tests.BaseTestFixture"); - baseClass.ProjectContent = projectContent; - baseMethod = new MockMethod("BaseTest"); + MockClass baseClass = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.BaseTestFixture"); + baseMethod = new MockMethod(baseClass, "BaseTest"); baseMethod.Attributes.Add(new MockAttribute("Test")); - baseMethod.DeclaringType = baseClass; baseClass.Methods.Add(baseMethod); - + // Create the derived test class. - c = new MockClass("ICSharpCode.SharpDevelop.Tests.MainTestFixture"); + c = new MockClass(projectContent, "ICSharpCode.SharpDevelop.Tests.MainTestFixture"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Set the base class for each class in the hierarchy. - c.BaseClass = baseClass; - baseClass.BaseClass = baseBaseClass; + c.AddBaseClass(baseClass); + baseClass.AddBaseClass(baseBaseClass); // Create TestClass. - testClass = new TestClass(c); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testClass = new TestClass(c, testFrameworks); } [Test] @@ -95,7 +92,7 @@ namespace UnitTesting.Tests.Project testClasses.Add(testClass); TestResult testResult = new TestResult("ICSharpCode.SharpDevelop.Tests.MainTestFixture.BaseBaseTest"); - testResult.IsFailure = true; + testResult.ResultType = TestResultType.Failure; testClasses.UpdateTestResult(testResult); Assert.AreEqual(TestResultType.Failure, testClass.Result); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs index dd03364edf..894ac3d60e 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Project/TwoProjectRootNamespacesTestFixture.cs @@ -19,7 +19,8 @@ namespace UnitTesting.Tests.Project { TestProject testProject; MockProjectContent projectContent; - + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + [SetUp] public void Init() { @@ -33,18 +34,17 @@ namespace UnitTesting.Tests.Project // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - MockClass c = new MockClass("RootNamespace1.MyTestFixture1"); + MockClass c = new MockClass(projectContent, "RootNamespace1.MyTestFixture1"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); // Add a second class with a different root namespace. - c = new MockClass("RootNamespace2.MyTestFixture2"); + c = new MockClass(projectContent, "RootNamespace2.MyTestFixture2"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; projectContent.Classes.Add(c); - - testProject = new TestProject(project, projectContent); + + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + testProject = new TestProject(project, projectContent, testFrameworks); } [Test] @@ -123,13 +123,12 @@ namespace UnitTesting.Tests.Project [Test] public void DuplicateClassName() { - MockClass c = new MockClass("RootNamespace1.MyTestFixture2"); + MockClass c = new MockClass(projectContent, "RootNamespace1.MyTestFixture2"); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; - TestClass testClass = new TestClass(c); + TestClass testClass = new TestClass(c, testFrameworks); testProject.TestClasses.Add(testClass); - + testClass.Result = TestResultType.Failure; TestClass testClass2 = testProject.TestClasses["RootNamespace2.MyTestFixture2"]; testClass2.Result = TestResultType.Failure; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/AddNUnitReferenceToProjectTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/AddNUnitReferenceToProjectTestFixture.cs new file mode 100644 index 0000000000..eb243ef23f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/AddNUnitReferenceToProjectTestFixture.cs @@ -0,0 +1,59 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class AddNUnitReferenceToProjectTestFixture + { + MockCSharpProject project; + ReferenceProjectItem referenceProjectItem; + AddNUnitReferenceCommand command = new AddNUnitReferenceCommand(); + + [SetUp] + public void Init() + { + project = new MockCSharpProject(); + + command.Run(project); + + if (project.Items.Count > 0) { + referenceProjectItem = project.Items[0] as ReferenceProjectItem; + } + } + + [Test] + public void ProjectHasNUnitFrameworkReferenceAdded() + { + Assert.AreEqual("nunit.framework", referenceProjectItem.Name); + } + + [Test] + public void NUnitReferenceProjectPropertyEqualsProjectPassedToRunMethod() + { + Assert.AreEqual(project, referenceProjectItem.Project); + } + + [Test] + public void ProjectIsSaved() + { + Assert.IsTrue(project.IsSaved); + } + + [Test] + public void NoExceptionThrownWhenProjectIsNull() + { + Assert.DoesNotThrow(delegate { command.Run(null); }); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/BuildErrorWhenRunningTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/BuildErrorWhenRunningTestsTestFixture.cs new file mode 100644 index 0000000000..15ca6c62f3 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/BuildErrorWhenRunningTestsTestFixture.cs @@ -0,0 +1,63 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class BuildErrorWhenRunningTestsTestFixture : RunTestCommandTestFixtureBase + { + MockBuildProjectBeforeTestRun buildProjectBeforeTestRun; + + [SetUp] + public void Init() + { + base.InitBase(); + + MockCSharpProject project = new MockCSharpProject(); + context.MockUnitTestsPad.AddProject(project); + + buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun); + + runTestCommand.Run(); + + FileName fileName = new FileName("test.cs"); + context.MockTaskService.Add(new Task(fileName, String.Empty, 1, 1, TaskType.Error)); + + BuildError error = new BuildError(); + buildProjectBeforeTestRun.LastBuildResults.Add(error); + buildProjectBeforeTestRun.FireBuildCompleteEvent(); + } + + [Test] + public void RunTestMethodIsNotCalled() + { + Assert.AreEqual(0, runTestCommand.Helpers.Count); + } + + [Test] + public void IsOnStopMethodCalledReturnsTrue() + { + Assert.IsTrue(runTestCommand.IsOnStopMethodCalled); + } + + [Test] + public void IsRunningTestReturnsFalseAfterStopMethodCalled() + { + Assert.IsFalse(AbstractRunTestCommand.IsRunningTest); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/BuildProjectBeforeTestRunTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/BuildProjectBeforeTestRunTestFixture.cs new file mode 100644 index 0000000000..88fd597f9d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/BuildProjectBeforeTestRunTestFixture.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class BuildProjectBeforeTestRunTestFixture + { + BuildProjectBeforeTestRun buildProjectBeforeTestRun; + MockSaveAllFilesCommand saveAllFilesCommand; + MockCSharpProject project; + + [SetUp] + public void Init() + { + if (!PropertyService.Initialized) { + PropertyService.InitializeServiceForUnitTests(); + } + saveAllFilesCommand = new MockSaveAllFilesCommand(); + project = new MockCSharpProject(); + BuildResults buildResults = new BuildResults(); + + buildProjectBeforeTestRun = new BuildProjectBeforeTestRun(project, saveAllFilesCommand); + } + + [Test] + public void SaveAllFilesCommandNotCalledInitially() + { + Assert.IsFalse(saveAllFilesCommand.IsSaveAllFilesMethodCalled); + } + + [Test] + public void BeforeBuildMethodSavesAllFiles() + { + buildProjectBeforeTestRun.BeforeBuild(); + Assert.IsTrue(saveAllFilesCommand.IsSaveAllFilesMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs new file mode 100644 index 0000000000..6f038338de --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassTestFixtureSelectedTestFixture.cs @@ -0,0 +1,64 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class ClassTestFixtureSelectedTestFixture + { + SelectedTests selectedTests; + List projects; + MockCSharpProject project; + MockClass c; + + [SetUp] + public void Init() + { + projects = new List(); + projects.Add(new MockCSharpProject()); + projects.Add(new MockCSharpProject()); + + project = new MockCSharpProject(); + + c = new MockClass(); + + MockTestTreeView treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + treeView.SelectedClass = c; + + selectedTests = new SelectedTests(treeView, projects.ToArray()); + } + + [Test] + public void SelectedTestsHasOneProject() + { + IProject[] expectedProjects = new IProject[] { project }; + List actualProjects = new List(selectedTests.Projects); + + Assert.AreEqual(expectedProjects, actualProjects.ToArray()); + } + + [Test] + public void ProjectPropertyReturnsSelectedProject() + { + Assert.AreEqual(project, selectedTests.Project); + } + + [Test] + public void ClassPropertyReturnsSelectedClass() + { + Assert.AreEqual(c, selectedTests.Class); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs index 900fabbf54..1872235a41 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/ClassWithNoRootNamespaceTestFixture.cs @@ -34,6 +34,7 @@ namespace UnitTesting.Tests.Tree ExtTreeNode testFixtureNode; TreeNodeCollection rootChildNodes; MockProjectContent projectContent; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() @@ -51,13 +52,12 @@ namespace UnitTesting.Tests.Tree // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - testClass = new MockClass("MyTestFixture"); + testClass = new MockClass(projectContent, "MyTestFixture"); testClass.Attributes.Add(new MockAttribute("TestFixture")); - testClass.ProjectContent = projectContent; projectContent.Classes.Add(testClass); - - // Init mock project content to be returned. - dummyTreeView = new DummyParserServiceTestTreeView(); + + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + dummyTreeView = new DummyParserServiceTestTreeView(testFrameworks); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. @@ -126,13 +126,12 @@ namespace UnitTesting.Tests.Tree [Test] public void AddNewClass() - { + { TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; - MockClass mockClass = new MockClass("MyNewTestFixture"); + MockClass mockClass = new MockClass(projectContent, "MyNewTestFixture"); mockClass.Attributes.Add(new MockAttribute("TestFixture")); - mockClass.ProjectContent = projectContent; - TestClass newTestClass = new TestClass(mockClass); + TestClass newTestClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(newTestClass); ExtTreeNode newTestClassNode = null; @@ -197,7 +196,8 @@ namespace UnitTesting.Tests.Tree // and make sure the disposed class node does // not add a new child node. Assert.AreEqual(0, testClassNode.Nodes.Count); - MockMethod mockMethod = new MockMethod("Method"); + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + MockMethod mockMethod = new MockMethod(c, "Method"); TestMethod testMethod = new TestMethod(mockMethod); testClass.TestMethods.Add(testMethod); @@ -295,8 +295,8 @@ namespace UnitTesting.Tests.Tree // Make sure the project node child nodes are // unaffected when the test class is removed. Assert.AreEqual(1, projectNode.Nodes.Count); - MockClass mockClass = new MockClass("MyNewTestClass"); - TestClass testClass = new TestClass(mockClass); + MockClass mockClass = new MockClass(projectContent, "MyNewTestClass"); + TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); Assert.AreEqual(1, projectNode.Nodes.Count); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GetProjectsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GetProjectsTestFixture.cs index 1a14c6ef9f..0446743d94 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/GetProjectsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GetProjectsTestFixture.cs @@ -26,6 +26,7 @@ namespace UnitTesting.Tests.Tree MSBuildBasedProject project2; IProject[] projects; DummyParserServiceTestTreeView treeView; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -46,7 +47,8 @@ namespace UnitTesting.Tests.Tree MockProjectContent projectContent = new MockProjectContent(); projectContent.Project = project1; - treeView = new DummyParserServiceTestTreeView(); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + treeView = new DummyParserServiceTestTreeView(testFrameworks); treeView.ProjectContentForProject = projectContent; treeView.AddSolution(solution); projects = treeView.GetProjects(); @@ -102,7 +104,7 @@ namespace UnitTesting.Tests.Tree foreach (IProject project in projects) { TestProject testProject = treeView.GetTestProject(project); MockClass mockClass = new MockClass("MyTestFixture"); - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); testClass.Result = TestResultType.Failure; testProject.TestClasses.Add(testClass); Assert.AreEqual(testProject.TestClasses.Result, TestResultType.Failure); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs new file mode 100644 index 0000000000..6eafda3b29 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedBaseClassMethodTestFixture.cs @@ -0,0 +1,57 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class GoToSelectedBaseClassMethodTestFixture + { + MockTestTreeView treeView; + GotoDefinitionCommand gotoDefinitionCommand; + MockFileService fileService; + MockMethod baseClassMethod; + + [SetUp] + public void Init() + { + baseClassMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); + baseClassMethod.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs"; + + MockClass derivedClass = MockClass.CreateMockClassWithoutAnyAttributes(); + derivedClass.CompilationUnit.FileName = @"d:\projects\myderivedtestclass.cs"; + + int methodBeginLine = 3; // 1 based. + int methodBeginColumn = 6; // 1 based. + baseClassMethod.Region = new DomRegion(methodBeginLine, methodBeginColumn); + + BaseTestMethod baseTestMethod = new BaseTestMethod(derivedClass, baseClassMethod); + + treeView = new MockTestTreeView(); + treeView.SelectedMethod = baseTestMethod; + fileService = new MockFileService(); + gotoDefinitionCommand = new GotoDefinitionCommand(fileService); + gotoDefinitionCommand.Owner = treeView; + gotoDefinitionCommand.Run(); + } + + [Test] + public void MethodIsJumpedTo() + { + int line = 2; // zero based. + int col = 5; // zero based. + FilePosition expectedFilePos = new FilePosition(@"c:\projects\mytest.cs", line, col); + + Assert.AreEqual(expectedFilePos, fileService.FilePositionJumpedTo); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedClassTestFixture.cs new file mode 100644 index 0000000000..9411e909a7 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedClassTestFixture.cs @@ -0,0 +1,51 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class GoToSelectedClassTestFixture + { + MockTestTreeView treeView; + GotoDefinitionCommand gotoDefinitionCommand; + MockFileService fileService; + + [SetUp] + public void Init() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.CompilationUnit.FileName = @"c:\projects\mytest.cs"; + + int beginLine = 3; // 1 based. + int beginColumn = 6; // 1 based. + c.Region = new DomRegion(beginLine, beginColumn); + + treeView = new MockTestTreeView(); + treeView.SelectedClass = c; + fileService = new MockFileService(); + gotoDefinitionCommand = new GotoDefinitionCommand(fileService); + gotoDefinitionCommand.Owner = treeView; + gotoDefinitionCommand.Run(); + } + + [Test] + public void ClassIsJumpedTo() + { + int line = 2; // zero based. + int col = 5; // zero based. + FilePosition expectedFilePos = new FilePosition(@"c:\projects\mytest.cs", line, col); + + Assert.AreEqual(expectedFilePos, fileService.FilePositionJumpedTo); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedClassWithNoLocationTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedClassWithNoLocationTestFixture.cs new file mode 100644 index 0000000000..9012cc129f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedClassWithNoLocationTestFixture.cs @@ -0,0 +1,43 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class GoToSelectedClassWithNoLocationTestFixture + { + MockTestTreeView treeView; + GotoDefinitionCommand gotoDefinitionCommand; + MockFileService fileService; + + [SetUp] + public void Init() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.CompilationUnit.FileName = @"c:\projects\mytest.cs"; + + treeView = new MockTestTreeView(); + treeView.SelectedClass = c; + fileService = new MockFileService(); + gotoDefinitionCommand = new GotoDefinitionCommand(fileService); + gotoDefinitionCommand.Owner = treeView; + gotoDefinitionCommand.Run(); + } + + [Test] + public void FileIsOpenedInsteadOfJumpingToFileLocation() + { + Assert.AreEqual(@"c:\projects\mytest.cs", fileService.FileOpened); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedMethodTestFixture.cs new file mode 100644 index 0000000000..4ccf80c70d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedMethodTestFixture.cs @@ -0,0 +1,66 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class GoToSelectedMethodTestFixture + { + MockTestTreeView treeView; + GotoDefinitionCommand gotoDefinitionCommand; + MockFileService fileService; + MockMethod method; + + [SetUp] + public void Init() + { + method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs"; + + int methodBeginLine = 3; // 1 based. + int methodBeginColumn = 6; // 1 based. + method.Region = new DomRegion(methodBeginLine, methodBeginColumn); + + treeView = new MockTestTreeView(); + treeView.SelectedMethod = method; + fileService = new MockFileService(); + gotoDefinitionCommand = new GotoDefinitionCommand(fileService); + gotoDefinitionCommand.Owner = treeView; + gotoDefinitionCommand.Run(); + } + + [Test] + public void MethodIsJumpedTo() + { + int line = 2; // zero based. + int col = 5; // zero based. + FilePosition expectedFilePos = new FilePosition(@"c:\projects\mytest.cs", line, col); + + Assert.AreEqual(expectedFilePos, fileService.FilePositionJumpedTo); + } + + [Test] + public void ExceptionNotThrownWhenSelectedTestTreeMethodIsNull() + { + treeView.SelectedMethod = null; + Assert.DoesNotThrow(delegate { gotoDefinitionCommand.Run(); }); + } + + [Test] + public void ExceptionNotThrownWhenCommandOwnerIsNull() + { + gotoDefinitionCommand.Owner = null; + Assert.DoesNotThrow(delegate { gotoDefinitionCommand.Run(); }); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedMethodWithNoLocationTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedMethodWithNoLocationTestFixture.cs new file mode 100644 index 0000000000..95ff346b36 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/GoToSelectedMethodWithNoLocationTestFixture.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class GoToSelectedMethodWithNoLocationTestFixture + { + MockTestTreeView treeView; + GotoDefinitionCommand gotoDefinitionCommand; + MockFileService fileService; + MockMethod method; + + [SetUp] + public void Init() + { + method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.DeclaringType.CompilationUnit.FileName = @"c:\projects\mytest.cs"; + + treeView = new MockTestTreeView(); + treeView.SelectedMethod = method; + fileService = new MockFileService(); + gotoDefinitionCommand = new GotoDefinitionCommand(fileService); + gotoDefinitionCommand.Owner = treeView; + gotoDefinitionCommand.Run(); + } + + [Test] + public void FileIsOpenedInsteadOfJumpingToFileLocation() + { + Assert.AreEqual(@"c:\projects\mytest.cs", fileService.FileOpened); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/MethodTestSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/MethodTestSelectedTestFixture.cs new file mode 100644 index 0000000000..ebe9a5e624 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/MethodTestSelectedTestFixture.cs @@ -0,0 +1,79 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class MethodTestSelectedTestFixture + { + SelectedTests selectedTests; + List projects; + MockCSharpProject project; + MockMethod method; + MockClass c; + + [SetUp] + public void Init() + { + projects = new List(); + projects.Add(new MockCSharpProject()); + projects.Add(new MockCSharpProject()); + + project = new MockCSharpProject(); + + c = new MockClass(); + method = new MockMethod(c); + + MockTestTreeView treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + treeView.SelectedNamespace = "MyNamespace"; + treeView.SelectedMethod = method; + + selectedTests = new SelectedTests(treeView, projects.ToArray()); + } + + [Test] + public void SelectedTestsHasOneProject() + { + IProject[] expectedProjects = new IProject[] { project }; + List actualProjects = new List(selectedTests.Projects); + + Assert.AreEqual(expectedProjects, actualProjects.ToArray()); + } + + [Test] + public void ProjectPropertyReturnsSelectedProject() + { + Assert.AreEqual(project, selectedTests.Project); + } + + [Test] + public void NamespaceFilterIsMyNamespace() + { + Assert.AreEqual("MyNamespace", selectedTests.NamespaceFilter); + } + + [Test] + public void MethodPropertyReturnsSelectedMethod() + { + Assert.AreEqual(method, selectedTests.Method); + } + + [Test] + public void ClassPropertyReturnsMethodDeclaringType() + { + Assert.AreEqual(c, selectedTests.Class); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/MultipleTestProjectsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/MultipleTestProjectsTestFixture.cs index f2092c519d..0b5fa59f2c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/MultipleTestProjectsTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/MultipleTestProjectsTestFixture.cs @@ -28,11 +28,13 @@ namespace UnitTesting.Tests.Tree TestProject firstTestProject; TestProject secondTestProject; Solution solution; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() { - treeView = new DummyParserServiceTestTreeView(); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + treeView = new DummyParserServiceTestTreeView(testFrameworks); // Create a solution with two test projects. solution = new Solution(); @@ -115,7 +117,7 @@ namespace UnitTesting.Tests.Tree [Test] public void ProjectIgnoredTestResult() { - TestClass c = new TestClass(new MockClass("Tests.TestFixture")); + TestClass c = new TestClass(new MockClass("Tests.TestFixture"), testFrameworks); firstTestProject.TestClasses.Add(c); c.Result = TestResultType.Ignored; @@ -137,7 +139,7 @@ namespace UnitTesting.Tests.Tree ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); // Add the project into a dummy project node. - TestProject testProject = new TestProject(project, new MockProjectContent()); + TestProject testProject = new TestProject(project, new MockProjectContent(), testFrameworks); DerivedTestProjectTreeNode projectNode = new DerivedTestProjectTreeNode(testProject); allTestsTreeNode.AddProjectNode(projectNode); @@ -154,7 +156,7 @@ namespace UnitTesting.Tests.Tree [Test] public void ProjectFailedTestResult() { - TestClass c = new TestClass(new MockClass("Tests.TestFixture")); + TestClass c = new TestClass(new MockClass("Tests.TestFixture"), testFrameworks); firstTestProject.TestClasses.Add(c); c.Result = TestResultType.Failure; @@ -164,7 +166,7 @@ namespace UnitTesting.Tests.Tree [Test] public void ProjectPassedTestResult() { - TestClass c = new TestClass(new MockClass("Tests.TestFixture")); + TestClass c = new TestClass(new MockClass("Tests.TestFixture"), testFrameworks); firstTestProject.TestClasses.Add(c); c.Result = TestResultType.Success; @@ -187,11 +189,11 @@ namespace UnitTesting.Tests.Tree [Test] public void AllTestProjectsPassed() { - TestClass c = new TestClass(new MockClass("Tests.TestFixture")); + TestClass c = new TestClass(new MockClass("Tests.TestFixture"), testFrameworks); firstTestProject.TestClasses.Add(c); c.Result = TestResultType.Success; - c = new TestClass(new MockClass("Tests.TestFixture")); + c = new TestClass(new MockClass("Tests.TestFixture"), testFrameworks); secondTestProject.TestClasses.Add(c); c.Result = TestResultType.Success; diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoOwnerForSelectedTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoOwnerForSelectedTestsTestFixture.cs new file mode 100644 index 0000000000..cf78ca72cf --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoOwnerForSelectedTestsTestFixture.cs @@ -0,0 +1,53 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class NoOwnerForSelectedTestsTestFixture + { + SelectedTests selectedTests; + List projects; + + [SetUp] + public void Init() + { + projects = new List(); + projects.Add(new MockCSharpProject()); + projects.Add(new MockCSharpProject()); + projects.Add(new MockCSharpProject()); + + selectedTests = new SelectedTests(null, projects.ToArray()); + } + + [Test] + public void SelectedTestsHaveThreeProjects() + { + Assert.AreEqual(3, selectedTests.Projects.Count); + } + + [Test] + public void SelectedProjectsMatchProjectsPassedToConstructor() + { + List actualProjects = new List(selectedTests.Projects); + Assert.AreEqual(projects.ToArray(), actualProjects.ToArray()); + } + + [Test] + public void ProjectPropertyReturnsFirstProject() + { + Assert.AreEqual(selectedTests.Project, projects[0]); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs new file mode 100644 index 0000000000..c27d735883 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenNoTestsSelectedTestFixture.cs @@ -0,0 +1,30 @@ +// +// +// +// +// $Revision$ +// + +using System; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class NoTestsRunWhenNoTestsSelectedTestFixture : RunTestCommandTestFixtureBase + { + [SetUp] + public void Init() + { + base.InitBase(); + runTestCommand.Run(); + } + + [Test] + public void OnBeforeRunIsNotCalled() + { + Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs new file mode 100644 index 0000000000..d327f4ed96 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/NoTestsRunWhenUnitTestPadNotCreatedTestFixture.cs @@ -0,0 +1,42 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class NoTestsRunWhenUnitTestPadNotCreatedTestFixture + { + DerivedRunTestCommand runTestCommand; + MockRunTestCommandContext runTestCommandContext; + + [SetUp] + public void Init() + { + runTestCommandContext = new MockRunTestCommandContext(); + runTestCommand = new DerivedRunTestCommand(runTestCommandContext); + } + + [Test] + public void RunTestCommandRunMethodDoesNotThrowNullReferenceException() + { + Assert.DoesNotThrow(delegate { runTestCommand.Run(); }); + } + + [Test] + public void OnBeforeRunIsNotCalled() + { + runTestCommand.Run(); + Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/NonTestProjectNotAddedToTestTreeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/NonTestProjectNotAddedToTestTreeTestFixture.cs new file mode 100644 index 0000000000..5f9ef704af --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/NonTestProjectNotAddedToTestTreeTestFixture.cs @@ -0,0 +1,81 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + public class NonTestProjectNotAddedToTestTreeTestFixture + { + Solution solution; + MSBuildBasedProject testProject; + MSBuildBasedProject nonTestProject; + DummyParserServiceTestTreeView treeView; + IProject[] projects; + MockRegisteredTestFrameworks testFrameworks; + + [SetUp] + public void Init() + { + solution = new Solution(); + testProject = new MockCSharpProject(solution, "A"); + solution.Folders.Add(testProject); + + nonTestProject = new MockCSharpProject(solution, "Z"); + solution.Folders.Add(nonTestProject); + + MockProjectContent projectContent = new MockProjectContent(); + + testFrameworks = new MockRegisteredTestFrameworks(); + testFrameworks.AddTestProject(testProject); + + treeView = new DummyParserServiceTestTreeView(testFrameworks); + treeView.ProjectContentForProject = projectContent; + treeView.AddSolution(solution); + projects = treeView.GetProjects(); + } + + [TearDown] + public void TearDown() + { + if (treeView != null) { + treeView.Dispose(); + } + } + + [Test] + public void OneProjectInTestTree() + { + Assert.AreEqual(1, projects.Length); + } + + [Test] + public void TestProjectIsInTree() + { + bool found = false; + foreach (IProject project in projects) { + found = Object.ReferenceEquals(project, testProject); + if (found) { + break; + } + } + Assert.IsTrue(found); + } + + [Test] + public void asdfasdf() + { + Assert.IsNotNull(testFrameworks.IsTestProjectParameterUsed); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs index e419f918cf..2c83a50c71 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/OneTestClassTestFixture.cs @@ -41,6 +41,7 @@ namespace UnitTesting.Tests.Tree TreeNodeCollection testFixtureChildNodes; ExtTreeNode testNode; ReferenceProjectItem nunitFrameworkReferenceItem; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() @@ -60,27 +61,23 @@ namespace UnitTesting.Tests.Tree // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - testClass = new MockClass("RootNamespace.Tests.MyTestFixture"); - testClass.Namespace = "RootNamespace.Tests"; + testClass = new MockClass(projectContent, "RootNamespace.Tests.MyTestFixture"); testClass.Attributes.Add(new MockAttribute("TestFixture")); - testClass.ProjectContent = projectContent; projectContent.Classes.Add(testClass); // Add two methods to the test class only // one of which has test attributes. - testMethod = new MockMethod("NameExists"); + testMethod = new MockMethod(testClass, "NameExists"); testMethod.Attributes.Add(new MockAttribute("Test")); - testMethod.DeclaringType = testClass; testClass.Methods.Add(testMethod); - testClass.Methods.Add(new MockMethod()); - + testClass.Methods.Add(new MockMethod(testClass)); + // Add a second class that has no test fixture attribute. - MockClass nonTestClass = new MockClass(); - nonTestClass.ProjectContent = projectContent; + MockClass nonTestClass = new MockClass(projectContent); projectContent.Classes.Add(nonTestClass); - // Init mock project content to be returned. - dummyTreeView = new DummyParserServiceTestTreeView(); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + dummyTreeView = new DummyParserServiceTestTreeView(testFrameworks); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. @@ -99,12 +96,12 @@ namespace UnitTesting.Tests.Tree rootNamespaceNode.Expanding(); rootNamespaceChildNodes = rootNamespaceNode.Nodes; testsNamespaceNode = (ExtTreeNode)rootNamespaceNode.Nodes[0]; - + // Expand the tests namespace node. testsNamespaceNode.Expanding(); testsNamespaceChildNodes = testsNamespaceNode.Nodes; testFixtureNode = (ExtTreeNode)testsNamespaceNode.Nodes[0]; - + // Expand the test node. testFixtureNode.Expanding(); testFixtureChildNodes = testFixtureNode.Nodes; @@ -316,7 +313,7 @@ namespace UnitTesting.Tests.Tree public void TestMethodFails() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.NameExists"); - result.IsFailure = true; + result.ResultType = TestResultType.Failure; TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; projectNode.TestProject.UpdateTestResult(result); @@ -331,7 +328,7 @@ namespace UnitTesting.Tests.Tree public void TestMethodPasses() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.NameExists"); - result.IsSuccess = true; + result.ResultType = TestResultType.Success; TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; projectNode.TestProject.UpdateTestResult(result); @@ -345,7 +342,7 @@ namespace UnitTesting.Tests.Tree public void TestMethodIgnored() { TestResult result = new TestResult("RootNamespace.Tests.MyTestFixture.NameExists"); - result.IsIgnored = true; + result.ResultType = TestResultType.Ignored; TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; projectNode.TestProject.UpdateTestResult(result); @@ -379,8 +376,7 @@ namespace UnitTesting.Tests.Tree TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; TestClass testClass = projectNode.TestProject.TestClasses["RootNamespace.Tests.MyTestFixture"]; - MockMethod method = new MockMethod("NewMethod"); - method.DeclaringType = testClass.Class; + MockMethod method = new MockMethod(testClass.Class, "NewMethod"); method.Attributes.Add(new MockAttribute("Test")); testClass.TestMethods.Add(new TestMethod(method)); @@ -391,7 +387,7 @@ namespace UnitTesting.Tests.Tree break; } } - + Assert.AreEqual(2, testFixtureNode.Nodes.Count); Assert.IsNotNull(newMethodNode); Assert.IsInstanceOf(typeof(TestMethodTreeNode), newMethodNode); @@ -469,7 +465,7 @@ namespace UnitTesting.Tests.Tree TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; ProjectService.RemoveProjectItem(projectNode.TestProject.Project, nunitFrameworkReferenceItem); - treeView.ProjectReferencesChanged(projectNode.TestProject.Project); + treeView.ProjectItemRemoved(nunitFrameworkReferenceItem); Assert.AreEqual(0, treeView.Nodes.Count); } @@ -478,7 +474,12 @@ namespace UnitTesting.Tests.Tree public void UnknownProjectHasReferenceRemoved() { IProject project = new MockCSharpProject(); - treeView.ProjectReferencesChanged(project); + ReferenceProjectItem refItem = new ReferenceProjectItem(project); + refItem.Include = "System"; + + ProjectService.AddProjectItem(project, refItem); + + treeView.ProjectItemRemoved(refItem); Assert.AreEqual(1, treeView.Nodes.Count); } @@ -492,17 +493,18 @@ namespace UnitTesting.Tests.Tree nunitFrameworkReferenceItem.Include = "NUnit.Framework"; ProjectService.AddProjectItem(project, nunitFrameworkReferenceItem); - treeView.ProjectReferencesChanged(project); + treeView.ProjectItemAdded(nunitFrameworkReferenceItem); + ExtTreeNode allProjectsNode = treeView.Nodes[0] as ExtTreeNode; ExtTreeNode newProjectNode = null; - foreach (ExtTreeNode node in treeView.Nodes) { + foreach (ExtTreeNode node in allProjectsNode.Nodes) { if (node.Text == "NewProject") { newProjectNode = node; break; } } - Assert.AreEqual(2, treeView.Nodes.Count); + Assert.AreEqual(1, treeView.Nodes.Count); Assert.IsNotNull(newProjectNode); } @@ -548,7 +550,7 @@ namespace UnitTesting.Tests.Tree testsNamespaceNode.Remove(); TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; - + // Make sure the tests namespace node child nodes are // unaffected when the test class is removed. Assert.AreEqual(1, testsNamespaceNode.Nodes.Count); @@ -568,7 +570,7 @@ namespace UnitTesting.Tests.Tree testsNamespaceNode.Remove(); TestProjectTreeNode projectNode = (TestProjectTreeNode)rootNode; - + // Make sure the tests namespace node image index is // unaffected when the test class test result is changed. Assert.AreEqual(TestTreeViewImageListIndex.TestNotRun, (TestTreeViewImageListIndex)testsNamespaceNode.ImageIndex); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RemoveSolutionFolderTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RemoveSolutionFolderTestFixture.cs new file mode 100644 index 0000000000..62d545b551 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RemoveSolutionFolderTestFixture.cs @@ -0,0 +1,89 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RemoveSolutionFolderTestFixture + { + DummyParserServiceTestTreeView treeView; + MockCSharpProject project; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + + [SetUp] + public void Init() + { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + treeView = new DummyParserServiceTestTreeView(testFrameworks); + treeView.ProjectContentForProject = new MockProjectContent(); + + project = new MockCSharpProject(); + project.Name = "MyProject"; + + ReferenceProjectItem refProjectItem = new ReferenceProjectItem(project); + refProjectItem.Include = "NUnit.Framework"; + ProjectService.AddProjectItem(project, refProjectItem); + + treeView.AddProject(project); + } + + [TearDown] + public void TearDown() + { + if (treeView != null) { + treeView.Dispose(); + } + } + + [Test] + public void TreeViewHasOneRootProjectNodeCalledMyProject() + { + TestProjectTreeNode node = treeView.Nodes[0] as TestProjectTreeNode; + Assert.AreEqual("MyProject", node.Text); + } + + [Test] + public void RemovingNullSolutionFolderDoesNotThrowNullReferenceException() + { + Assert.DoesNotThrow(delegate { treeView.RemoveSolutionFolder(null); }); + } + + [Test] + public void RemovingHeavilyNestedSolutionFoldersWithProjectAsChildRemovesProjectTreeNodeFromTreeView() + { + SolutionFolder childSolutionFolder = new SolutionFolder("child", "location", "guid"); + childSolutionFolder.Folders.Add(project); + + SolutionFolder parentSolutionFolder = new SolutionFolder("parent", "location", "guid"); + parentSolutionFolder.Folders.Add(childSolutionFolder); + + SolutionFolder grandParentSolutionFolder = new SolutionFolder("grandparent", "location", "guid"); + grandParentSolutionFolder.Folders.Add(parentSolutionFolder); + + treeView.RemoveSolutionFolder(grandParentSolutionFolder); + + Assert.AreEqual(0, treeView.Nodes.Count); + } + + [Test] + public void RemovingSolutionFolderContainingProjectRemovesProjectNodeFromTreeView() + { + SolutionFolder solutionFolder = new SolutionFolder("parent", "location", "guid"); + solutionFolder.Folders.Add(project); + + treeView.RemoveSolutionFolder(solutionFolder); + + Assert.AreEqual(0, treeView.Nodes.Count); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunAllTestsInPadTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunAllTestsInPadTestFixture.cs new file mode 100644 index 0000000000..8398dc271a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunAllTestsInPadTestFixture.cs @@ -0,0 +1,36 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunAllTestsInPadTestFixture + { + RunAllTestsInPadCommand runAllTestsInPadCommand; + + [SetUp] + public void Init() + { + MockRunTestCommandContext context = new MockRunTestCommandContext(); + runAllTestsInPadCommand = new RunAllTestsInPadCommand(context); + runAllTestsInPadCommand.Owner = this; + runAllTestsInPadCommand.Run(); + } + + [Test] + public void OwnerIsSetToNullWhenRunMethodIsCalled() + { + Assert.IsNull(runAllTestsInPadCommand.Owner); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs new file mode 100644 index 0000000000..bb4366ab4e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsForMethodTestFixture.cs @@ -0,0 +1,221 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Util; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunNUnitTestsForMethodTestFixture + { + MockNUnitTestRunnerContext context; + SelectedTests selectedTests; + NUnitTestRunner testRunner; + + [SetUp] + public void Init() + { + selectedTests = SelectedTestsHelper.CreateSelectedTestMethod(); + context = new MockNUnitTestRunnerContext(); + FileUtility.ApplicationRootPath = @"C:\SharpDevelop"; + + testRunner = context.CreateNUnitTestRunner(); + testRunner.Start(selectedTests); + } + + [Test] + public void StartMethodCallsTestResultsMonitorStartMethod() + { + Assert.IsTrue(context.MockTestResultsMonitor.IsStartMethodCalled); + } + + [Test] + public void StopMethodCallsTestResultsMonitorStopMethod() + { + testRunner.Stop(); + Assert.IsTrue(context.MockTestResultsMonitor.IsStopMethodCalled); + } + + [Test] + public void DisposeMethodCallsTestResultsMonitorDisposeMethod() + { + testRunner.Dispose(); + Assert.IsTrue(context.MockTestResultsMonitor.IsDisposeMethodCalled); + } + + [Test] + public void NUnitTestRunnerIsIDisposable() + { + Assert.IsNotNull(testRunner as IDisposable); + } + + [Test] + public void StopMethodCallsTestResultsReadMethodToEnsureAllTestsAreRead() + { + testRunner.Stop(); + Assert.IsTrue(context.MockTestResultsMonitor.IsReadMethodCalled); + } + + [Test] + public void StopMethodCallsProcessRunnerKillMethod() + { + testRunner.Stop(); + Assert.IsTrue(context.MockProcessRunner.IsKillMethodCalled); + } + + [Test] + public void FiringTestResultsMonitorTestFinishedEventFiresNUnitTestRunnerTestFinishedEvent() + { + TestResult testResultToFire = new TestResult("abc"); + TestResult resultFromEventHandler = FireTestResult(testResultToFire); + Assert.IsNotNull(resultFromEventHandler); + } + + TestResult FireTestResult(TestResult testResult) + { + TestResult resultFired = null; + testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) { + resultFired = e.Result; + }; + + context.MockTestResultsMonitor.FireTestFinishedEvent(testResult); + return resultFired; + } + + [Test] + public void FiringTestResultsMonitorTestFinishedCreatesNUnitTestResultWithCorrectNameFromNUnitTestRunnerTestFinishedEvent() + { + TestResult testResultToFire = new TestResult("abc"); + NUnitTestResult resultFromEventHandler = FireTestResult(testResultToFire) as NUnitTestResult; + Assert.AreEqual("abc", resultFromEventHandler.Name); + } + + [Test] + public void FiringTestResultsMonitorTestFinishedEventAfterDisposingTestRunnerDoesNotGenerateTestFinishedEvent() + { + bool fired = false; + testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) { + fired = true; + }; + + testRunner.Dispose(); + + TestResult result = new TestResult("abc"); + context.MockTestResultsMonitor.FireTestFinishedEvent(result); + Assert.IsFalse(fired); + } + + [Test] + public void NUnitTestRunnerImplementsITestRunner() + { + Assert.IsNotNull(testRunner as ITestRunner); + } + + [Test] + public void FiringProcessExitEventCausesTestRunnerAllTestsFinishedEventToFire() + { + bool fired = false; + testRunner.AllTestsFinished += delegate (object source, EventArgs e) { + fired = true; + }; + context.MockProcessRunner.FireProcessExitedEvent(); + + Assert.IsTrue(fired); + } + + [Test] + public void NUnitConsoleExeProcessIsStarted() + { + string expectedCommand = @"C:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe"; + Assert.AreEqual(expectedCommand, context.MockProcessRunner.CommandPassedToStartMethod); + } + + [Test] + public void NUnitConsoleExeProcessIsStartedWithArgumentsToTestSingleMethod() + { + string expectedArgs = + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + + "/results=\"c:\\temp\\tmp66.tmp\" " + + "/run=\"MyTests.MyTestClass.MyTestMethod\""; + Assert.AreEqual(expectedArgs, context.MockProcessRunner.CommandArgumentsPassedToStartMethod); + } + + [Test] + public void NUnitConsoleWorkingDirectoryIsUsedByProcessRunner() + { + string expectedDirectory = @"C:\SharpDevelop\bin\Tools\NUnit"; + Assert.AreEqual(expectedDirectory, context.MockProcessRunner.WorkingDirectory); + } + + [Test] + public void ProcessRunnerLogStandardOutputAndErrorIsFalse() + { + Assert.IsFalse(context.MockProcessRunner.LogStandardOutputAndError); + } + + [Test] + public void FiringProcessRunnerOutputLineReceivedEventFiresTestRunnerMessageReceivedEvent() + { + string message = null; + testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) { + message = e.Message; + }; + + string expectedMessage = "test"; + context.MockProcessRunner.FireOutputLineReceivedEvent(new LineReceivedEventArgs(expectedMessage)); + + Assert.AreEqual(expectedMessage, message); + } + + [Test] + public void FiringProcessRunnerErrorLineReceivedEventFiresTestRunnerMessageReceivedEvent() + { + string message = null; + testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) { + message = e.Message; + }; + + string expectedMessage = "test"; + context.MockProcessRunner.FireErrorLineReceivedEvent(new LineReceivedEventArgs(expectedMessage)); + + Assert.AreEqual(expectedMessage, message); + } + + [Test] + public void FiringProcessRunnerOutputLineReceivedEventAfterDisposingTestRunnerDoesNotMessageReceivedEvent() + { + string message = null; + testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) { + message = e.Message; + }; + + testRunner.Dispose(); + context.MockProcessRunner.FireOutputLineReceivedEvent(new LineReceivedEventArgs("Test")); + + Assert.IsNull(message); + } + + [Test] + public void FiringProcessRunnerErrorLineReceivedEventAfterDisposingTestRunnerDoesNotMessageReceivedEvent() + { + string message = null; + testRunner.MessageReceived += delegate (object o, MessageReceivedEventArgs e) { + message = e.Message; + }; + + testRunner.Dispose(); + context.MockProcessRunner.FireErrorLineReceivedEvent(new LineReceivedEventArgs("Test")); + + Assert.IsNull(message); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs new file mode 100644 index 0000000000..550e9d178d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunNUnitTestsWithDebuggerTestFixture.cs @@ -0,0 +1,303 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunNUnitTestsWithDebuggerTestFixture + { + MockTestResultsMonitor testResultsMonitor; + SelectedTests selectedTests; + NUnitTestDebugger testDebugger; + MockDebuggerService debuggerService; + MockDebugger debugger; + MockMessageService messageService; + UnitTestingOptions options; + + [SetUp] + public void Init() + { + selectedTests = SelectedTestsHelper.CreateSelectedTestMethod(); + FileUtility.ApplicationRootPath = @"C:\SharpDevelop"; + + messageService = new MockMessageService(); + debuggerService = new MockDebuggerService(); + debugger = debuggerService.MockDebugger; + testResultsMonitor = new MockTestResultsMonitor(); + testResultsMonitor.FileName = @"c:\temp\tmp66.tmp"; + options = new UnitTestingOptions(new Properties()); + options.NoShadow = true; + testDebugger = new NUnitTestDebugger(debuggerService, messageService, testResultsMonitor, options); + } + + [Test] + public void DebuggerProcessStartInfoFileNameIsNUnitConsoleApp() + { + StartTestDebugger(); + string expectedCommandLine = + @"C:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe"; + + Assert.AreEqual(expectedCommandLine, debugger.ProcessStartInfo.FileName); + } + + void StartTestDebugger() + { + testDebugger.Start(selectedTests); + } + + [Test] + public void DebuggerProcessStartInfoArgumentsIsNUnitConsoleCommandLineArguments() + { + StartTestDebugger(); + string expectedArguments = + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + + "/noshadow " + + "/results=\"c:\\temp\\tmp66.tmp\" " + + "/run=\"MyTests.MyTestClass.MyTestMethod\""; + + Assert.AreEqual(expectedArguments, debugger.ProcessStartInfo.Arguments); + } + + [Test] + public void DebuggerProcessStartInfoWorkingDirectoryIsNUnitConsoleAppDirectory() + { + StartTestDebugger(); + string expectedDirectory = @"C:\SharpDevelop\bin\Tools\NUnit"; + + Assert.AreEqual(expectedDirectory, debugger.ProcessStartInfo.WorkingDirectory); + } + + [Test] + public void StopCallsDebuggerStopIfDebuggerIsDebugging() + { + StartTestDebugger(); + debugger.IsDebugging = true; + testDebugger.Stop(); + + Assert.IsTrue(debugger.IsStopCalled); + } + + [Test] + public void StopDoesNotCallDebuggerStopIfDebuggerIsNotDebugging() + { + StartTestDebugger(); + debugger.IsDebugging = false; + testDebugger.Stop(); + + Assert.IsFalse(debugger.IsStopCalled); + } + + [Test] + public void FiringDebuggerDebugStopEventFiresAllTestsFinishedEvent() + { + StartTestDebugger(); + + bool fired = false; + testDebugger.AllTestsFinished += delegate (object o, EventArgs e) { + fired = true; + }; + debugger.FireDebugStoppedEvent(); + + Assert.IsTrue(fired); + } + + [Test] + public void FiringDebuggerDebugStopEventTwiceFiresAllTestsFinishedEventOnlyOnce() + { + StartTestDebugger(); + + int eventFiredCount = 0; + testDebugger.AllTestsFinished += delegate (object o, EventArgs e) { + eventFiredCount++; + }; + debugger.FireDebugStoppedEvent(); + debugger.FireDebugStoppedEvent(); + + Assert.AreEqual(1, eventFiredCount); + } + + [Test] + public void FiringDebugStopEventAfterDebuggerThrowsExceptionOnStartDoesNotFireAllTestsFinishedEvent() + { + debugger.ThrowExceptionOnStart = new ApplicationException(); + try { + StartTestDebugger(); + } catch { + // Do nothing. + } + + bool fired = false; + testDebugger.AllTestsFinished += delegate (object o, EventArgs e) { + fired = true; + }; + debugger.FireDebugStoppedEvent(); + + Assert.IsFalse(fired); + } + + [Test] + public void FiringTestResultsMonitorEventFiresTestFinishedEventWithNUnitTestResult() + { + TestResult actualTestResult = null; + testDebugger.TestFinished += delegate (object o, TestFinishedEventArgs e) { + actualTestResult = e.Result; + }; + TestResult testResult = new TestResult("test"); + testResultsMonitor.FireTestFinishedEvent(testResult); + + TestResult nunitTestResult = actualTestResult as NUnitTestResult; + + Assert.AreEqual("test", nunitTestResult.Name); + } + + [Test] + public void MessageReceivedEventFiredShowingCommandLineWhenDebuggerStarted() + { + string message = null; + testDebugger.MessageReceived += delegate(object sender, MessageReceivedEventArgs e) { + message = e.Message; + }; + StartTestDebugger(); + + string commandLine = "\"C:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\" " + + "/noshadow " + + "/results=\"c:\\temp\\tmp66.tmp\" " + + "/run=\"MyTests.MyTestClass.MyTestMethod\""; + Assert.AreEqual(commandLine, message); + } + + [Test] + public void IfDebuggerIsRunningWhenStartMethodCalledUserIsPromptedToStopDebugger() + { + SetDebuggerIsLoadedToTrueAndDebuggingToTrue(); + StartTestDebugger(); + string expectedQuestion = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}"; + + Assert.AreEqual(expectedQuestion, messageService.Question); + } + + void SetDebuggerIsLoadedToTrueAndDebuggingToTrue() + { + debuggerService.IsDebuggerLoaded = true; + debuggerService.MockDebugger.IsDebugging = true; + } + + [Test] + public void UserNotPromptedToStopDebuggerWhenDebuggerIsLoadedAndDebuggerIsNotDebugging() + { + debuggerService.IsDebuggerLoaded = true; + debuggerService.MockDebugger.IsDebugging = false; + StartTestDebugger(); + + Assert.IsNull(messageService.Question); + } + + [Test] + public void UserNotPromptedToStopDebuggerWhenDebuggerIsNotLoadedAndDebuggerIsDebugging() + { + debuggerService.IsDebuggerLoaded = false; + debuggerService.MockDebugger.IsDebugging = true; + StartTestDebugger(); + + Assert.IsNull(messageService.Question); + } + + [Test] + public void IfDebuggerIsRunningWhenStartMethodCalledUserIsPromptedToStopDebuggerWithCaption() + { + SetDebuggerIsLoadedToTrueAndDebuggingToTrue(); + StartTestDebugger(); + string expectedCaption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}"; + + Assert.AreEqual(expectedCaption, messageService.Caption); + } + + [Test] + public void DebuggerStoppedIfUserClicksYesToStopDebuggerPrompt() + { + messageService.AskQuestionReturnValue = true; + SetDebuggerIsLoadedToTrueAndDebuggingToTrue(); + StartTestDebugger(); + + Assert.IsTrue(debugger.IsStopCalled); + } + + [Test] + public void DebuggerNotStoppedIfUserClicksNoToStopDebuggerPrompt() + { + UserClicksNoToStopDebuggerPrompt(); + + Assert.IsFalse(debugger.IsStopCalled); + } + + void UserClicksNoToStopDebuggerPrompt() + { + messageService.AskQuestionReturnValue = false; + SetDebuggerIsLoadedToTrueAndDebuggingToTrue(); + StartTestDebugger(); + } + + [Test] + public void DebuggerNotStartedIfUserClicksNoToStopDebuggerPrompt() + { + UserClicksNoToStopDebuggerPrompt(); + + Assert.IsNull(debugger.ProcessStartInfo); + } + + [Test] + public void IfUserSaysYesToStopDebuggingPromptThenDebuggerIsStarted() + { + SetDebuggerIsLoadedToTrueAndDebuggingToTrue(); + messageService.AskQuestionReturnValue = true; + StartTestDebugger(); + + Assert.IsNotNull(debugger.ProcessStartInfo); + } + + [Test] + public void TestResultsMonitorIsStartedWhenDebuggerIsStarted() + { + StartTestDebugger(); + Assert.IsTrue(testResultsMonitor.IsStartMethodCalled); + } + + [Test] + public void StoppingDebuggerAlsoStopsTestResultsMonitor() + { + StartTestDebugger(); + testDebugger.Stop(); + + Assert.IsTrue(testResultsMonitor.IsStopMethodCalled); + } + + [Test] + public void StoppingDebuggerCausesTestResultsMonitorReadMethodToBeCalled() + { + StartTestDebugger(); + testDebugger.Stop(); + + Assert.IsTrue(testResultsMonitor.IsReadMethodCalled); + } + + [Test] + public void DisposingDebuggerDisposesTestResultsMonitor() + { + StartTestDebugger(); + testDebugger.Dispose(); + + Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsInPadTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsInPadTestFixture.cs new file mode 100644 index 0000000000..27b7248463 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsInPadTestFixture.cs @@ -0,0 +1,64 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunProjectTestsInPadTestFixture + { + RunProjectTestsInPadCommand runProjectTestsInPadCommand; + + [SetUp] + public void Init() + { + MockRunTestCommandContext context = new MockRunTestCommandContext(); + runProjectTestsInPadCommand = new RunProjectTestsInPadCommand(context); + runProjectTestsInPadCommand.Owner = this; + runProjectTestsInPadCommand.Run(); + } + + [Test] + public void OwnerIsSetToCommandWhenRunMethodIsCalled() + { + Assert.AreEqual(runProjectTestsInPadCommand, runProjectTestsInPadCommand.Owner); + } + + [Test] + public void SelectedMethodIsNull() + { + Assert.IsNull(runProjectTestsInPadCommand.SelectedMethod); + } + + [Test] + public void SelectedClassIsNull() + { + Assert.IsNull(runProjectTestsInPadCommand.SelectedClass); + } + + [Test] + public void SelectedNamespaceIsNull() + { + Assert.IsNull(runProjectTestsInPadCommand.SelectedNamespace); + } + + [Test] + public void SelectedProjectMatchesProjectServiceCurrentProject() + { + MockCSharpProject project = new MockCSharpProject(); + ProjectService.CurrentProject = project; + + Assert.AreEqual(project, runProjectTestsInPadCommand.SelectedProject); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs new file mode 100644 index 0000000000..6a85703da2 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunProjectTestsTestFixture.cs @@ -0,0 +1,201 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunProjectTestsTestFixture : RunTestCommandTestFixtureBase + { + MockCSharpProject project; + TestProject testProject; + TestResult errorTestResult; + TestMethod firstTestMethod; + TestResult warningTestResult; + TestMethod secondTestMethod; + TestResult successTestResult; + TestMethod thirdTestMethod; + MockTestFramework testFramework; + bool runningTestsBeforeTestsFinishedCalled; + + [SetUp] + public void Init() + { + base.InitBase(); + + project = new MockCSharpProject(); + context.MockUnitTestsPad.AddProject(project); + + string[] methodNames = new string[] { "FirstTest", "SecondTest", "ThirdTest" }; + + testProject = + TestProjectHelper.CreateTestProjectWithTestClassTestMethods(project, + "MyTests.MyTestClass", + methodNames); + + TestClass testClass = testProject.TestClasses[0]; + firstTestMethod = testClass.TestMethods[0]; + secondTestMethod = testClass.TestMethods[1]; + thirdTestMethod = testClass.TestMethods[2]; + + context.MockUnitTestsPad.AddTestProject(testProject); + + MockBuildProjectBeforeTestRun buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun); + + context.UnitTestingOptions.NoThread = true; + context.UnitTestingOptions.NoShadow = true; + context.UnitTestingOptions.NoLogo = true; + context.UnitTestingOptions.NoDots = true; + context.UnitTestingOptions.Labels = true; + context.UnitTestingOptions.CreateXmlOutputFile = true; + + testFramework = new MockTestFramework(); + context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework); + + runTestCommand.Run(); + + buildProjectBeforeTestRun.FireBuildCompleteEvent(); + + errorTestResult = new TestResult("MyTests.MyTestClass.FirstTest"); + errorTestResult.ResultType = TestResultType.Failure; + + warningTestResult = new TestResult("MyTests.MyTestClass.SecondTest"); + warningTestResult.ResultType = TestResultType.Ignored; + + successTestResult = new TestResult("MyTests.MyTestClass.ThirdTest"); + successTestResult.ResultType = TestResultType.Success; + + context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true; + MockTestRunner testRunner = runTestCommand.TestRunnersCreated[0]; + testRunner.FireTestFinishedEvent(errorTestResult); + testRunner.FireTestFinishedEvent(warningTestResult); + testRunner.FireTestFinishedEvent(successTestResult); + + context.MockUnitTestsPad.IsUpdateToolbarMethodCalled = false; + runningTestsBeforeTestsFinishedCalled = AbstractRunTestCommand.IsRunningTest; + runTestCommand.CallTestsCompleted(); + } + + [Test] + public void RegisteredTestFrameworksReturnsTestFrameworkForProject() + { + Assert.AreEqual(testFramework, context.MockRegisteredTestFrameworks.GetTestFrameworkForProject(project)); + } + + [Test] + public void FirstSafeAsyncMethodCallWithArgsIsMadeOnRunTestCommandShowResultsMethod() + { + ActionArguments actionArgs = new ActionArguments(); + actionArgs.Action = runTestCommand.ShowResultAction; + actionArgs.Arg = errorTestResult; + + Assert.AreEqual(actionArgs, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCallsWithArguments[0]); + } + + [Test] + public void FirstTaskAddedToTaskServiceIsErrorTask() + { + Task expectedTask = TestResultTask.Create(errorTestResult, testProject); + TaskComparison taskComparison = new TaskComparison(expectedTask, context.MockTaskService.Tasks[0]); + Assert.IsTrue(taskComparison.IsMatch, taskComparison.MismatchReason); + } + + [Test] + public void FirstTaskMethodRegionIsTakenFromTestProject() + { + DomRegion expectedRegion = new DomRegion(4, 19); + Task task = context.MockTaskService.Tasks[0]; + DomRegion region = new DomRegion(task.Line, task.Column); + Assert.AreEqual(expectedRegion, region); + } + + [Test] + public void UnitTestsPadGetProjectReturnsTestProject() + { + Assert.AreEqual(testProject, context.MockUnitTestsPad.GetTestProject(testProject.Project)); + } + + [Test] + public void FirstTestMethodResultTypeIsFailure() + { + Assert.AreEqual(TestResultType.Failure, firstTestMethod.Result); + } + + [Test] + public void SecondTaskAddedToTaskServiceIsWarningTask() + { + Task expectedTask = TestResultTask.Create(warningTestResult, testProject); + TaskComparison taskComparison = new TaskComparison(expectedTask, context.MockTaskService.Tasks[1]); + Assert.IsTrue(taskComparison.IsMatch, taskComparison.MismatchReason); + } + + [Test] + public void SecondTestMethodResultTypeIsIgnored() + { + Assert.AreEqual(TestResultType.Ignored, secondTestMethod.Result); + } + + [Test] + public void TaskServiceOnlyHasTwoTasksSinceSuccessTestResultsDoNotCreateTasks() + { + Assert.AreEqual(2, context.MockTaskService.Tasks.Count); + } + + [Test] + public void ThirdTestMethodResultTypeIsSuccess() + { + Assert.AreEqual(TestResultType.Success, thirdTestMethod.Result); + } + + [Test] + public void IsRunningTestsReturnsTrueBeforeTestsFinishedMethodIsCalled() + { + Assert.IsTrue(runningTestsBeforeTestsFinishedCalled); + } + + [Test] + public void IsRunningTestsReturnsTrueAfterTestsFinishedMethodCalled() + { + Assert.IsFalse(AbstractRunTestCommand.IsRunningTest); + } + + [Test] + public void IsUnitTestsPadToolbarUpdatedAfterTestFinishedMethodCalled() + { + Assert.IsTrue(context.MockUnitTestsPad.IsUpdateToolbarMethodCalled); + } + + [Test] + public void OnAfterRunTestsCalledAfterTestFinishedMethodCalled() + { + Assert.IsTrue(runTestCommand.IsOnAfterRunTestsMethodCalled); + } + + [Test] + public void ErrorListPadDescriptorExistsInWorkbench() + { + Assert.IsNotNull(context.MockUnitTestWorkbench.GetPad(typeof(ErrorListPad))); + } + + [Test] + public void ErrorListPadBroughtToFrontAfterTestsFinishedCalled() + { + Action expectedAction = context.MockUnitTestWorkbench.ErrorListPadDescriptor.BringPadToFront; + Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[1]); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs new file mode 100644 index 0000000000..d1171a03c3 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandBeforeRunTestFixture.cs @@ -0,0 +1,166 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestCommandBeforeRunTestFixture : RunTestCommandTestFixtureBase + { + MockCSharpProject project; + MockBuildProjectBeforeTestRun buildProjectBeforeTestRun; + + [SetUp] + public void Init() + { + base.InitBase(); + project = new MockCSharpProject(); + context.MockUnitTestsPad.AddProject(project); + + buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun); + + context.MockTaskService.BuildMessageViewCategory.SetText("Previous build text..."); + context.UnitTestCategory.SetText("Previous unit test run..."); + } + + [Test] + public void RunningTestCommandPropertyIsNullByDefault() + { + Assert.IsNull(AbstractRunTestCommand.RunningTestCommand); + } + + [Test] + public void IsRunningTestReturnsFalseByDefault() + { + Assert.IsFalse(AbstractRunTestCommand.IsRunningTest); + } + + [Test] + public void RunCallsOnBeforeRunTestsMethod() + { + runTestCommand.Run(); + Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); + } + + [Test] + public void TaskServiceClearExceptCommentTasksMethodIsCalled() + { + runTestCommand.Run(); + Assert.IsTrue(context.MockTaskService.IsClearExceptCommentTasksMethodCalled); + } + + [Test] + public void TaskServiceIsInUpdateWhilstClearExceptCommentTasksMethodIsCalled() + { + runTestCommand.Run(); + Assert.IsTrue(context.MockTaskService.IsInUpdateWhilstClearExceptCommentTasksMethodCalled); + } + + [Test] + public void TaskServiceInUpdateReturnsFalseAfterRunMethodCompletes() + { + runTestCommand.Run(); + Assert.IsFalse(context.MockTaskService.InUpdate); + } + + [Test] + public void TaskServiceBuildMessageViewCategoryHasTextBeforeRunMethodCalled() + { + Assert.IsTrue(context.MockTaskService.BuildMessageViewCategory.Text.Length > 0); + } + + [Test] + public void TaskServiceBuildMessageViewCategoryTextIsClearedAfterRunMethodCalled() + { + runTestCommand.Run(); + Assert.AreEqual(String.Empty, context.MockTaskService.BuildMessageViewCategory.Text); + } + + [Test] + public void TestRunnerMessageViewCategoryHasTextBeforeRunMethodCalled() + { + Assert.IsTrue(context.UnitTestCategory.Text.Length > 0); + } + + [Test] + public void TestRunnerMessageViewCategoryTextIsClearedAfterRunMethodCalled() + { + runTestCommand.Run(); + Assert.AreEqual(String.Empty, context.UnitTestCategory.Text); + } + + [Test] + public void UnitTestsPadToolbarUpdatedAfterRunMethodCalled() + { + runTestCommand.Run(); + Assert.IsTrue(context.MockUnitTestsPad.IsUpdateToolbarMethodCalled); + } + + [Test] + public void UnitTestsPadBringToFrontMethodCalledAfterRunMethodCalled() + { + runTestCommand.Run(); + Assert.IsTrue(context.MockUnitTestsPad.IsBringToFrontMethodCalled); + } + + [Test] + public void CompilerMessageViewPadDescriptorExistsInWorkbench() + { + Assert.IsNotNull(context.MockUnitTestWorkbench.GetPad(typeof(CompilerMessageView))); + } + + [Test] + public void CompilerMessageViewPadBroughtToFrontAfterRunMethodCalled() + { + runTestCommand.Run(); + Action expectedAction = context.MockUnitTestWorkbench.CompilerMessageViewPadDescriptor.BringPadToFront; + Assert.AreEqual(expectedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]); + } + + [Test] + public void RunningTestCommandPropertyIsSetToRunningCommandWhenOnBeforeRunIsCalled() + { + runTestCommand.Run(); + Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); + } + + [Test] + public void IsRunningTestPropertyReturnsTrueWhenOnBeforeRunIsCalled() + { + runTestCommand.Run(); + Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); + } + + [Test] + public void IsUnitTestsPadResetTestResultsMethodCalled() + { + runTestCommand.Run(); + Assert.IsTrue(context.MockUnitTestsPad.IsResetTestResultsMethodCalled); + } + + [Test] + public void BuildProjectBeforeTestRunIsCreatedWhenRunMethodCalled() + { + runTestCommand.Run(); + Assert.AreEqual(project, buildProjectBeforeTestRun.Project); + } + + [Test] + public void BuildProjectBeforeTestRunHasRunMethodCalledWhenRunTestCommandRunMethodCalled() + { + runTestCommand.Run(); + Assert.IsTrue(buildProjectBeforeTestRun.IsRunMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandTestFixtureBase.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandTestFixtureBase.cs new file mode 100644 index 0000000000..1262e11929 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestCommandTestFixtureBase.cs @@ -0,0 +1,40 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + public class RunTestCommandTestFixtureBase + { + protected DerivedRunTestCommand runTestCommand; + protected PadDescriptor compilerMessageViewPadDescriptor; + protected PadDescriptor errorListPadDescriptor; + protected MockRunTestCommandContext context; + + public void InitBase() + { + if (!PropertyService.Initialized) { + PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); + } + context = new MockRunTestCommandContext(); + runTestCommand = new DerivedRunTestCommand(context); + } + + [TearDown] + public void TearDownBase() + { + AbstractRunTestCommand.RunningTestCommand = null; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs new file mode 100644 index 0000000000..3d79c2af6c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestInPadCommandTestFixture.cs @@ -0,0 +1,173 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Util; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestInPadCommandTestFixture + { + string oldRootPath; + DerivedRunTestInPadCommand runCommand; + MockProcessRunner processRunner; + NUnitConsoleApplication helper; + MockRunTestCommandContext context; + MockNUnitTestFramework testFramework; + MockBuildProjectBeforeTestRun buildProject; + + [TestFixtureSetUp] + public void SetUpFixture() + { + oldRootPath = FileUtility.ApplicationRootPath; + FileUtility.ApplicationRootPath = @"D:\SharpDevelop"; + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + FileUtility.ApplicationRootPath = oldRootPath; + } + + [SetUp] + public void Init() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests selectedTests = new SelectedTests(project); + helper = new NUnitConsoleApplication(selectedTests); + + context = new MockRunTestCommandContext(); + context.MockUnitTestsPad.AddProject(project); + + buildProject = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject); + + processRunner = new MockProcessRunner(); + + testFramework = new MockNUnitTestFramework(processRunner, context.MockTestResultsMonitor, context.UnitTestingOptions); + context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework); + + runCommand = new DerivedRunTestInPadCommand(context); + } + + [Test] + public void LogStandardOutputAndErrorIsSetToFalse() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + Assert.IsFalse(processRunner.LogStandardOutputAndError); + } + + [Test] + public void RunTestsStartsProcessWithCommandForUnitTestApplication() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + string expectedCommand = @"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe"; + + Assert.AreEqual(expectedCommand, processRunner.CommandPassedToStartMethod); + } + + [Test] + public void RunTestsStartsProcessWithCommandLineArgumentsForUnitTestApplication() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + string expectedArgs = "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + + Assert.AreEqual(expectedArgs, processRunner.CommandArgumentsPassedToStartMethod); + } + + [Test] + public void MessageCategoryDisplaysUnitTestApplicationCommandLine() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + string fullCommandLine = helper.GetCommandLine(); + string expectedCategoryText = fullCommandLine + "\r\n"; + + Assert.AreEqual(expectedCategoryText, context.UnitTestCategory.Text); + } + + [Test] + public void ProcessRunnerKillMethodCalledAfterStopMethodCalled() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + runCommand.Stop(); + Assert.IsTrue(processRunner.IsKillMethodCalled); + } + + [Test] + public void ProcessRunnerKillMethodIsNotCalledAfterStopMethodCalledTheSecondTime() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + runCommand.Stop(); + processRunner.IsKillMethodCalled = false; + runCommand.Stop(); + Assert.IsFalse(processRunner.IsKillMethodCalled); + } + + [Test] + public void TestRunnerIsDisposedAfterRunCommandStopMethodIsCalled() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + runCommand.Stop(); + Assert.IsTrue(context.MockTestResultsMonitor.IsDisposeMethodCalled); + } + + [Test] + public void OutputLineTextReceivedFromProcessRunnerIsAddedToMessageCategoryText() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + context.UnitTestCategory.ClearText(); + + LineReceivedEventArgs firstLineReceived = new LineReceivedEventArgs("first"); + processRunner.FireOutputLineReceivedEvent(firstLineReceived); + LineReceivedEventArgs secondLineReceived = new LineReceivedEventArgs("second"); + processRunner.FireOutputLineReceivedEvent(secondLineReceived); + + string expectedCategoryText = + "first\r\n" + + "second\r\n"; + + Assert.AreEqual(expectedCategoryText, context.UnitTestCategory.Text); + } + + [Test] + public void TestCompletedMethodIsCalledSafelyAndAsynchronouslyAfterProcessExitEventFires() + { + runCommand.Run(); + context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Clear(); + buildProject.FireBuildCompleteEvent(); + processRunner.FireProcessExitedEvent(); + + Action callTestRunCompletedAction = runCommand.GetCallRunTestCompletedAction(); + Assert.AreEqual(callTestRunCompletedAction, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]); + } + + [Test] + public void TestRunnerIsDisposedAfterAllTestsFinished() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + context.MockUnitTestWorkbench.MakeNonGenericSafeThreadAsyncMethodCalls = true; + processRunner.FireProcessExitedEvent(); + + Assert.IsTrue(context.MockTestResultsMonitor.IsDisposeMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWhenDebuggerRunningTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWhenDebuggerRunningTestFixture.cs new file mode 100644 index 0000000000..0087528740 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWhenDebuggerRunningTestFixture.cs @@ -0,0 +1,114 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestWhenDebuggerRunningTestFixture : RunTestWithDebuggerCommandTestFixtureBase + { + [SetUp] + public void Init() + { + base.InitBase(); + } + + [Test] + public void IfDebuggerLoadedAndCurrentDebuggerIsDebuggingUserIsAskedToStopDebugging() + { + SetDebuggerIsLoadedAndCurrentDebuggerIsDebuggingToTrue(); + RunTests(); + + string expectedQuestion = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingQuestion}"; + string actualQuestion = context.MockMessageService.Question; + + Assert.AreEqual(expectedQuestion, actualQuestion); + } + + void SetDebuggerIsLoadedAndCurrentDebuggerIsDebuggingToTrue() + { + debuggerService.MockDebugger.IsDebugging = true; + debuggerService.IsDebuggerLoaded = true; + } + + void RunTests() + { + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + } + + [Test] + public void IfDebuggerLoadedAndCurrentDebuggerIsDebuggingUserMessageBoxHasStopDebuggingCaption() + { + SetDebuggerIsLoadedAndCurrentDebuggerIsDebuggingToTrue(); + RunTests(); + + string expectedCaption = "${res:XML.MainMenu.RunMenu.Compile.StopDebuggingTitle}"; + string actualCaption = context.MockMessageService.Caption; + + Assert.AreEqual(expectedCaption, actualCaption); + } + + [Test] + public void IfDebuggerLoadedAndCurrentDebuggerIsDebuggingAndUserSaysYesToDialogThenDebuggerIsStopped() + { + SetDebuggerIsLoadedAndCurrentDebuggerIsDebuggingToTrue(); + SetMessageServiceAskQuestionToReturnTrue(); + RunTests(); + + Assert.IsTrue(debuggerService.MockDebugger.IsStopCalled); + } + + void SetMessageServiceAskQuestionToReturnTrue() + { + context.MockMessageService.AskQuestionReturnValue = true; + } + + [Test] + public void IfUserSaysYesToStopDebuggingDialogThenDebuggerIsStarted() + { + SetDebuggerIsLoadedAndCurrentDebuggerIsDebuggingToTrue(); + SetMessageServiceAskQuestionToReturnTrue(); + RunTests(); + + string expectedCommand = + @"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe"; + string actualCommand = debuggerService.MockDebugger.ProcessStartInfo.FileName; + + Assert.AreEqual(expectedCommand, actualCommand); + } + + [Test] + public void IfUserSaysNoToStopDebuggingDialogThenDebuggerIsNotStarted() + { + SetDebuggerIsLoadedAndCurrentDebuggerIsDebuggingToTrue(); + RunTests(); + + Assert.IsNull(debuggerService.MockDebugger.ProcessStartInfo); + } + + [Test] + public void IfDebuggerNotLoadedThenDebuggerIsNotStopped() + { + SetCurrentDebuggerIsDebuggingToTrue(); + SetMessageServiceAskQuestionToReturnTrue(); + RunTests(); + + Assert.IsFalse(debuggerService.MockDebugger.IsStopCalled); + } + + void SetCurrentDebuggerIsDebuggingToTrue() + { + debuggerService.MockDebugger.IsDebugging = true; + } + + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs new file mode 100644 index 0000000000..377b8578ad --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixture.cs @@ -0,0 +1,106 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestWithDebuggerCommandTestFixture : RunTestWithDebuggerCommandTestFixtureBase + { + [SetUp] + public void Init() + { + base.InitBase(); + runCommand.Run(); + buildProject.FireBuildCompleteEvent(); + } + + [Test] + public void DebuggerStartsUnitTestApplication() + { + string expectedFileName = + @"D:\SharpDevelop\bin\Tools\NUnit\nunit-console-x86.exe"; + string actualFileName = debuggerService.MockDebugger.ProcessStartInfo.FileName; + + Assert.AreEqual(expectedFileName, actualFileName); + } + + [Test] + public void DebuggerStartsUnitTestApplicationWithCorrectCommandLineArguments() + { + string expectedArguments = + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\""; + string actualArguments = debuggerService.MockDebugger.ProcessStartInfo.Arguments; + + Assert.AreEqual(expectedArguments, actualArguments); + } + + [Test] + public void DebuggerStartsUnitTestApplicationInUnitTestApplicationWorkingDirectory() + { + string expectedWorkingDirectory = @"D:\SharpDevelop\bin\Tools\NUnit"; + string actualWorkingDirectory = debuggerService.MockDebugger.ProcessStartInfo.WorkingDirectory; + + Assert.AreEqual(expectedWorkingDirectory, actualWorkingDirectory); + } + + [Test] + public void UnitTestApplicationCommandLineWrittenToUnitTestCategory() + { + string expectedText = + "\"D:\\SharpDevelop\\bin\\Tools\\NUnit\\nunit-console-x86.exe\" " + + "\"c:\\projects\\MyTests\\bin\\Debug\\MyTests.dll\"\r\n"; + string actualText = context.UnitTestCategory.Text; + + Assert.AreEqual(expectedText, actualText); + } + + [Test] + public void TestRunCompletedCalledAsynchronouslyAfterDebugStoppedEventFires() + { + context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Clear(); + debuggerService.MockDebugger.FireDebugStoppedEvent(); + Action expectedAction = runCommand.GetCallRunTestCompletedAction(); + Action actualAction = context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls[0]; + + Assert.AreEqual(expectedAction, actualAction); + } + + [Test] + public void DebugStopEventHandlerRemovedAfterFirstDebugStopEventOccurs() + { + context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Clear(); + debuggerService.MockDebugger.FireDebugStoppedEvent(); + debuggerService.MockDebugger.FireDebugStoppedEvent(); + + Assert.AreEqual(1, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Count); + } + + [Test] + public void StopMethodStopsDebuggerIfDebuggerIsRunning() + { + debuggerService.MockDebugger.IsDebugging = true; + runCommand.Stop(); + + Assert.IsTrue(debuggerService.MockDebugger.IsStopCalled); + } + + [Test] + public void StopMethodDoesNotStopDebuggerIfDebuggerIsNotRunning() + { + debuggerService.MockDebugger.IsDebugging = false; + runCommand.Stop(); + + Assert.IsFalse(debuggerService.MockDebugger.IsStopCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixtureBase.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixtureBase.cs new file mode 100644 index 0000000000..9007b6c8eb --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestWithDebuggerCommandTestFixtureBase.cs @@ -0,0 +1,73 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + public class RunTestWithDebuggerCommandTestFixtureBase + { + string oldRootPath = String.Empty; + protected DerivedRunTestWithDebuggerCommand runCommand; + protected MockDebuggerService debuggerService; + protected MockRunTestCommandContext context; + protected MockCSharpProject project; + protected MockBuildProjectBeforeTestRun buildProject; + protected MockNUnitTestFramework testFramework; + + [TestFixtureSetUp] + public void SetUpFixture() + { + oldRootPath = FileUtility.ApplicationRootPath; + FileUtility.ApplicationRootPath = @"D:\SharpDevelop"; + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + FileUtility.ApplicationRootPath = oldRootPath; + } + + public void InitBase() + { + project = new MockCSharpProject(); + buildProject = new MockBuildProjectBeforeTestRun(); + + context = new MockRunTestCommandContext(); + context.MockUnitTestsPad.AddProject(project); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject); + + debuggerService = new MockDebuggerService(); + testFramework = + new MockNUnitTestFramework(debuggerService, + context.MockTestResultsMonitor, + context.UnitTestingOptions, + context.MessageService); + context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework); + + runCommand = new DerivedRunTestWithDebuggerCommand(context); + } + + [Test] + public void ExpectedBuildProjectReturnedFromBuildFactory() + { + InitBase(); + Assert.AreEqual(buildProject, context.MockBuildProjectFactory.CreateBuildProjectBeforeTestRun(null)); + } + + [Test] + public void ExpectedTestFrameworkReturnedFromRegisteredFrameworks() + { + InitBase(); + Assert.AreEqual(testFramework, context.MockRegisteredTestFrameworks.GetTestFrameworkForProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForClassTestFixture.cs new file mode 100644 index 0000000000..e2024c4fd4 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForClassTestFixture.cs @@ -0,0 +1,73 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestsForClassTestFixture : RunTestCommandTestFixtureBase + { + MockTestTreeView treeView; + MockCSharpProject project; + MockClass classToTest; + + [SetUp] + public void Init() + { + base.InitBase(); + + project = new MockCSharpProject(); + MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject); + + classToTest = MockClass.CreateMockClassWithoutAnyAttributes(); + classToTest.SetDotNetName("MyTestClass"); + + treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + treeView.SelectedClass = classToTest; + + runTestCommand.Owner = treeView; + + runTestCommand.Run(); + + buildProject.FireBuildCompleteEvent(); + + TestResult result = new TestResult("MyTestClass"); + result.ResultType = TestResultType.Success; + context.MockTestResultsMonitor.FireTestFinishedEvent(result); + + runTestCommand.CallTestsCompleted(); + } + + [Test] + public void TestableConditionGetClassReturnsClassToTest() + { + Assert.AreEqual(classToTest, TestableCondition.GetClass(treeView)); + } + + [Test] + public void SelectedTestsHasClassConfigured() + { + MockTestRunner testRunner = runTestCommand.TestRunnersCreated[0]; + SelectedTests tests = testRunner.SelectedTestsPassedToStartMethod; + Assert.AreEqual(classToTest, tests.Class); + } + + [Test] + public void ErrorListPadIsNotShownWhenAllTestsPassed() + { + Assert.IsFalse(context.MockUnitTestWorkbench.TypesPassedToGetPadMethod.Contains(typeof(ErrorListPad))); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForMethodTestFixture.cs new file mode 100644 index 0000000000..68ebb8eaf0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForMethodTestFixture.cs @@ -0,0 +1,86 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestsForMethodTestFixture : RunTestCommandTestFixtureBase + { + MockTestTreeView treeView; + MockCSharpProject project; + MockClass classToTest; + MockMethod methodToTest; + + [SetUp] + public void Init() + { + base.InitBase(); + + project = new MockCSharpProject(); + MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject); + + methodToTest = MockMethod.CreateMockMethodWithoutAnyAttributes(); + methodToTest.FullyQualifiedName = "MyTests.MyTestClass.MyTestMethod"; + + classToTest = methodToTest.DeclaringType as MockClass; + classToTest.SetDotNetName("MyTests.MyTestClass"); + + treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + treeView.SelectedMethod = methodToTest; + + runTestCommand.Owner = treeView; + + runTestCommand.Run(); + + buildProject.FireBuildCompleteEvent(); + + context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true; + context.MockBuildOptions.ShowErrorListAfterBuild = false; + + TestResult result = new TestResult("MyTests.MyTestClass.MyTestMethod"); + result.ResultType = TestResultType.Failure; + context.MockTestResultsMonitor.FireTestFinishedEvent(result); + + runTestCommand.CallTestsCompleted(); + } + + [Test] + public void SelectedTestsHasTestMethodConfigured() + { + SelectedTests tests = runTestCommand.TestRunnersCreated[0].SelectedTestsPassedToStartMethod; + Assert.AreEqual(methodToTest, tests.Method); + } + + [Test] + public void TestableConditionGetMemberReturnsTestMethod() + { + Assert.AreEqual(methodToTest, TestableCondition.GetMember(treeView)); + } + + [Test] + public void SelectedTestsHasClassConfigured() + { + SelectedTests tests = runTestCommand.TestRunnersCreated[0].SelectedTestsPassedToStartMethod; + Assert.AreEqual(classToTest, tests.Class); + } + + [Test] + public void ErrorListPadNotDisplayedWhenShowErrorListPadAfterBuildIsFalse() + { + Assert.IsFalse(context.MockUnitTestWorkbench.TypesPassedToGetPadMethod.Contains(typeof(ErrorListPad))); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForNamespaceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForNamespaceTestFixture.cs new file mode 100644 index 0000000000..97d8796633 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsForNamespaceTestFixture.cs @@ -0,0 +1,53 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestsForNamespaceTestFixture : RunTestCommandTestFixtureBase + { + MockTestTreeView treeView; + MockCSharpProject project; + + [SetUp] + public void Init() + { + base.InitBase(); + + project = new MockCSharpProject(); + MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject); + + treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + treeView.SelectedNamespace = "MyNamespace"; + + runTestCommand.Owner = treeView; + runTestCommand.Run(); + buildProject.FireBuildCompleteEvent(); + } + + [Test] + public void TestableConditionGetNamespaceReturnsMyNamespace() + { + Assert.AreEqual("MyNamespace", TestableCondition.GetNamespace(treeView)); + } + + [Test] + public void SelectedTestsHasNamespaceFilter() + { + SelectedTests tests = runTestCommand.TestRunnersCreated[0].SelectedTestsPassedToStartMethod; + Assert.AreEqual("MyNamespace", tests.NamespaceFilter); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutBuildingProjectTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutBuildingProjectTestFixture.cs new file mode 100644 index 0000000000..23f772fb58 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutBuildingProjectTestFixture.cs @@ -0,0 +1,82 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestsWithoutBuildingProjectTestFixture : RunTestCommandTestFixtureBase + { + MockTestFramework testFramework; + MockBuildProjectBeforeTestRun buildProjectBeforeTestRun; + + [SetUp] + public void Init() + { + InitBase(); + + MockCSharpProject project1 = new MockCSharpProject(); + MockCSharpProject project2 = new MockCSharpProject(); + testFramework = new MockTestFramework(); + testFramework.IsBuildNeededBeforeTestRun = false; + context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project1, testFramework); + context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project2, testFramework); + + buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun); + + context.MockUnitTestsPad.AddProject(project1); + context.MockUnitTestsPad.AddProject(project2); + + runTestCommand.Run(); + } + + [Test] + public void TestRunnerIsStarted() + { + Assert.IsTrue(runTestCommand.TestRunnersCreated[0].IsStartCalled); + } + + [Test] + public void ProjectIsNotBuiltBeforeTestRun() + { + Assert.IsFalse(buildProjectBeforeTestRun.IsRunMethodCalled); + } + + [Test] + public void SaveAllFilesCommandIsRun() + { + Assert.IsTrue(context.MockSaveAllFilesCommand.IsSaveAllFilesMethodCalled); + } + + [Test] + public void WhenTestRunCompletedTheSecondProjectIsNotBuilt() + { + runTestCommand.CallTestsCompleted(); + Assert.IsFalse(buildProjectBeforeTestRun.IsRunMethodCalled); + } + + [Test] + public void WhenTestRunCompletedTheSecondTestRunnerIsStarted() + { + runTestCommand.CallTestsCompleted(); + Assert.IsTrue(runTestCommand.TestRunnersCreated[1].IsStartCalled); + } + + [Test] + public void WhenTestRunCompletedAllFilesAreSaved() + { + context.MockSaveAllFilesCommand.IsSaveAllFilesMethodCalled = false; + runTestCommand.CallTestsCompleted(); + Assert.IsTrue(context.MockSaveAllFilesCommand.IsSaveAllFilesMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs new file mode 100644 index 0000000000..91f63cedcb --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTestsWithoutUnitTestsPadTestFixture.cs @@ -0,0 +1,57 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTestsWithoutUnitTestsPadTestFixture : RunTestCommandTestFixtureBase + { + MockTestTreeView treeView; + MockCSharpProject project; + + [SetUp] + public void Init() + { + base.InitBase(); + + project = new MockCSharpProject(); + MockBuildProjectBeforeTestRun buildProject = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject); + + treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + + runTestCommand.Owner = treeView; + + context.MockUnitTestsPad = null; + runTestCommand.Run(); + + context.MockUnitTestWorkbench.MakeSafeThreadAsyncMethodCallsWithArguments = true; + TestResult testResult = new TestResult("MyTests.MyTestClass.UnknownTestMethod"); + testResult.ResultType = TestResultType.Failure; + context.MockTestResultsMonitor.FireTestFinishedEvent(testResult); + } + + [Test] + public void TestableConditionGetProjectReturnsSelectedProjectFromTreeView() + { + Assert.AreEqual(project, TestableCondition.GetProject(treeView)); + } + + [Test] + public void OnBeforeTestsRunMethodIsCalled() + { + Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs new file mode 100644 index 0000000000..ac8873f378 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/RunTwoProjectsTestsTestFixture.cs @@ -0,0 +1,74 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class RunTwoProjectsTestsTestFixture : RunTestCommandTestFixtureBase + { + TestProject testProject1; + MockCSharpProject project1; + TestProject testProject2; + MockCSharpProject project2; + MockBuildProjectBeforeTestRun buildProject1; + MockBuildProjectBeforeTestRun buildProject2; + + [SetUp] + public void Init() + { + base.InitBase(); + + project1 = new MockCSharpProject(); + testProject1 = + TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(project1, "testClass1", "testMethod1"); + + project2 = new MockCSharpProject(); + testProject2 = + TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(project1, "testClass2", "testMethod2"); + + context.MockUnitTestsPad.AddProject(project1); + context.MockUnitTestsPad.AddProject(project2); + context.MockUnitTestsPad.AddTestProject(testProject1); + context.MockUnitTestsPad.AddTestProject(testProject2); + + buildProject1 = new MockBuildProjectBeforeTestRun(); + buildProject2 = new MockBuildProjectBeforeTestRun(); + + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject1); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProject2); + + runTestCommand.Run(); + + buildProject1.FireBuildCompleteEvent(); + runTestCommand.CallTestsCompleted(); + } + + [Test] + public void IsRunningTestReturnsTrueSinceOneTestProject() + { + Assert.IsTrue(AbstractRunTestCommand.IsRunningTest); + } + + [Test] + public void SecondProjectIsBuilt() + { + Assert.IsTrue(buildProject2.IsRunMethodCalled); + } + + [Test] + public void IsRunningTestReturnsFalseAfterSecondProjectTestsHaveAllRun() + { + runTestCommand.CallTestsCompleted(); + Assert.IsFalse(AbstractRunTestCommand.IsRunningTest); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/SelectedTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/SelectedTestsTestFixture.cs new file mode 100644 index 0000000000..86aca135c7 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/SelectedTestsTestFixture.cs @@ -0,0 +1,95 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class SelectedTestsTestFixture + { + SelectedTests selectedTests; + MockCSharpProject project; + string namespaceFilter = "MyNamespace.Tests"; + MockClass c; + MockMethod method; + + [SetUp] + public void Init() + { + project = new MockCSharpProject(); + c = new MockClass(); + method = new MockMethod(c); + selectedTests = new SelectedTests(project, namespaceFilter, c, method); + } + + [Test] + public void ProjectPropertyMatchesProjectPassedToConstructor() + { + Assert.AreEqual(project, selectedTests.Project); + } + + [Test] + public void ClassPropertyMatchesClassPassedToConstructor() + { + Assert.AreEqual(c, selectedTests.Class); + } + + [Test] + public void MethodPropertyMatchesMethodPassedToConstructor() + { + Assert.AreEqual(method, selectedTests.Method); + } + + [Test] + public void ProjectsReturnsSingleItemContainingProjectPassedToConstructor() + { + List projects = new List(selectedTests.Projects); + IProject[] expectedProjects = new IProject[] { project }; + + Assert.AreEqual(expectedProjects, projects); + } + + [Test] + public void HasProjectsReturnsTrue() + { + Assert.IsTrue(selectedTests.HasProjects); + } + + [Test] + public void NamespaceFilterPropertyMatchesNamespaceFilterPassedToConstructor() + { + Assert.AreEqual(namespaceFilter, selectedTests.NamespaceFilter); + } + + [Test] + public void RemoveFirstProjectLeavesNoProjects() + { + selectedTests.RemoveFirstProject(); + Assert.AreEqual(0, selectedTests.Projects.Count); + } + + [Test] + public void HasProjectReturnsFalseAfterRemoveFirstProjectCalled() + { + selectedTests.RemoveFirstProject(); + Assert.IsFalse(selectedTests.HasProjects); + } + + [Test] + public void RemovingFirstProjectTwiceDoesNotThrowException() + { + selectedTests.RemoveFirstProject(); + Assert.DoesNotThrow(delegate { selectedTests.RemoveFirstProject(); }); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionLoadedAfterUnitTestsTreeDisposedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionLoadedAfterUnitTestsTreeDisposedTestFixture.cs new file mode 100644 index 0000000000..1bbb790d4c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionLoadedAfterUnitTestsTreeDisposedTestFixture.cs @@ -0,0 +1,35 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class SolutionLoadedAfterUnitTestsTreeDisposedTestFixture + { + DerivedUnitTestsPad pad; + + [SetUp] + public void Init() + { + pad = new DerivedUnitTestsPad(); + pad.Dispose(); + } + + [Test] + public void SolutionLoadedAfterTreeDisposedDoesNotThrowNullReferenceException() + { + Solution solution = new Solution(); + Assert.DoesNotThrow(delegate { pad.CallSolutionLoaded(solution); }); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs index 9a68d98c53..d4a519251d 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/SolutionOpenedTestFixture.cs @@ -27,6 +27,7 @@ namespace UnitTesting.Tests.Tree Solution solution; MSBuildBasedProject project; MockProjectContent projectContent; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [TestFixtureSetUp] public void SetUpFixture() @@ -37,6 +38,7 @@ namespace UnitTesting.Tests.Tree [SetUp] public void Init() { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); projectContent = new MockProjectContent(); pad.ProjectContent = projectContent; solution = new Solution(); @@ -166,10 +168,8 @@ namespace UnitTesting.Tests.Tree public void ParserInfoUpdated() { DefaultCompilationUnit newUnit = new DefaultCompilationUnit(pad.ProjectContent); - MockClass mockClass = new MockClass("MyTestFixture"); + MockClass mockClass = new MockClass(pad.ProjectContent, "MyTestFixture"); mockClass.Attributes.Add(new MockAttribute("TestFixture")); - mockClass.ProjectContent = pad.ProjectContent; - mockClass.SetCompoundClass(mockClass); newUnit.Classes.Add(mockClass); ExtTreeNode rootNode = (ExtTreeNode)pad.TestTreeView.Nodes[0]; @@ -211,7 +211,7 @@ namespace UnitTesting.Tests.Tree // Add a new class to a non-empty namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.MyTestFixture"); - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); Assert.AreEqual(1, projectNode.Nodes.Count, @@ -240,7 +240,7 @@ namespace UnitTesting.Tests.Tree // Add a new class to a namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); // Get the newly added namespace node. @@ -275,7 +275,7 @@ namespace UnitTesting.Tests.Tree // Add a new class to a non-empty namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); // Expand RootNamespace tree node. @@ -324,7 +324,7 @@ namespace UnitTesting.Tests.Tree // Add a new class to a non-empty namespace so it gets // added to a new namespace node. MockClass mockClass = new MockClass("RootNamespace.Tests.MyTestFixture"); - TestClass testClass = new TestClass(mockClass); + TestClass testClass = new TestClass(mockClass, testFrameworks); projectNode.TestProject.TestClasses.Add(testClass); // Get the root namespace node. diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/StartingDebuggerThrowsExceptionWhenStartingTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/StartingDebuggerThrowsExceptionWhenStartingTestsTestFixture.cs new file mode 100644 index 0000000000..ff5105c961 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/StartingDebuggerThrowsExceptionWhenStartingTestsTestFixture.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class StartingDebuggerThrowsExceptionWhenStartingTestsTestFixture : RunTestWithDebuggerCommandTestFixtureBase + { + [SetUp] + public void Init() + { + InitBase(); + + ApplicationException ex = new ApplicationException(); + debuggerService.MockDebugger.ThrowExceptionOnStart = ex; + runCommand.Run(); + + try { + Assert.Throws( + delegate { buildProject.FireBuildCompleteEvent(); }); + } catch { + // Do nothing. + } + } + + [Test] + public void FiringDebugStoppedEventDoesNotCallTestRunCompletedMethod() + { + context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Clear(); + debuggerService.MockDebugger.FireDebugStoppedEvent(); + + Assert.AreEqual(0, context.MockUnitTestWorkbench.SafeThreadAsyncMethodCalls.Count); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/StopRunningTestsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/StopRunningTestsTestFixture.cs new file mode 100644 index 0000000000..1f8d6a6097 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/StopRunningTestsTestFixture.cs @@ -0,0 +1,100 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class StopRunningTestsTestFixture : RunTestCommandTestFixtureBase + { + bool isUpdatedToolbarMethodCalledBeforeStopMethodCalled; + MockBuildProjectBeforeTestRun buildProjectBeforeTestRun; + MockTestFramework testFramework; + + [SetUp] + public void Init() + { + base.InitBase(); + + MockCSharpProject project = new MockCSharpProject(); + context.MockUnitTestsPad.AddProject(project); + + buildProjectBeforeTestRun = new MockBuildProjectBeforeTestRun(); + context.MockBuildProjectFactory.AddBuildProjectBeforeTestRun(buildProjectBeforeTestRun); + + testFramework = new MockTestFramework(); + context.MockRegisteredTestFrameworks.AddTestFrameworkForProject(project, testFramework); + + runTestCommand.Run(); + + context.MockUnitTestsPad.IsUpdateToolbarMethodCalled = false; + isUpdatedToolbarMethodCalledBeforeStopMethodCalled = context.MockUnitTestsPad.IsUpdateToolbarMethodCalled; + runTestCommand.Stop(); + } + + [Test] + public void IsOnStopMethodCalledReturnsTrue() + { + Assert.IsTrue(runTestCommand.IsOnStopMethodCalled); + } + + [Test] + public void IsRunningTestReturnsFalseAfterStopMethodCalled() + { + Assert.IsFalse(AbstractRunTestCommand.IsRunningTest); + } + + [Test] + public void RunningTestCommandPropertyReturnsNullAfterStopMethodCalled() + { + Assert.IsNull(AbstractRunTestCommand.RunningTestCommand); + } + + [Test] + public void IsUpdatedToolbarMethodCalledIsResetBeforeStopMethodCalled() + { + Assert.IsFalse(isUpdatedToolbarMethodCalledBeforeStopMethodCalled); + } + + [Test] + public void IsUpdatedToolbarMethodCalledAfterStopMethodCalled() + { + Assert.IsTrue(context.MockUnitTestsPad.IsUpdateToolbarMethodCalled); + } + + [Test] + public void BuildCompleteEventFiringDoesNotCauseTestsToRunAfterStopMethodCalled() + { + buildProjectBeforeTestRun.FireBuildCompleteEvent(); + Assert.AreEqual(0, runTestCommand.Helpers.Count); + } + + [Test] + public void ErrorListPadIsDisplayedWhenBuildCompleteEventIsFiredAfterStopMethodCalled() + { + FileName fileName = new FileName("test.cs"); + context.MockTaskService.Add(new Task(fileName, String.Empty, 1, 1, TaskType.Error)); + buildProjectBeforeTestRun.FireBuildCompleteEvent(); + Assert.IsTrue(context.MockUnitTestWorkbench.TypesPassedToGetPadMethod.Contains(typeof(ErrorListPad))); + } + + [Test] + public void StopMethodNotCalledAfterBuildCompleteEventFiresAfterStopMethodCalled() + { + context.MockTestResultsMonitor.IsStopMethodCalled = false; + buildProjectBeforeTestRun.FireBuildCompleteEvent(); + Assert.IsFalse(context.MockTestResultsMonitor.IsStopMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs new file mode 100644 index 0000000000..1861162cd4 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskTestFixture.cs @@ -0,0 +1,68 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class TestResultFailureTaskTestFixture + { + Task task; + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyNamespace.MyTests"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "Test failed"; + testResult.StackTrace = + "Test Error : MyTest.Test\r\n" + + "at TestResultTask.Create() in c:\\projects\\SharpDevelop\\TestResultTask.cs:line 45\r\n" + + "at MyTest.Test() in c:\\myprojects\\test\\..\\test\\mytest.cs:line 28\r\n" + + ""; + testResult.StackTraceFilePosition = + new FilePosition("c:\\myprojects\\test\\..\\test\\mytest.cs", 28, 1); + task = TestResultTask.Create(testResult, null); + } + + [Test] + public void TaskTypeIsError() + { + Assert.AreEqual(TaskType.Error, task.TaskType); + } + + [Test] + public void TaskMessageEqualsTestResultMessage() + { + Assert.AreEqual("Test failed", task.Description); + } + + [Test] + public void TaskFileNameMatchesFileNameInStackTrace() + { + string expectedFileName = @"c:\myprojects\test\mytest.cs"; + Assert.AreEqual(expectedFileName, task.FileName.ToString()); + } + + [Test] + public void TaskLineNumberIs28WhichIsEqualToNUnitErrorLine() + { + Assert.AreEqual(28, task.Line); + } + + [Test] + public void TaskColumnNumberIsOne() + { + Assert.AreEqual(1, task.Column); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs new file mode 100644 index 0000000000..cad417b723 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultFailureTaskWithNoMessageTestFixture.cs @@ -0,0 +1,42 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class TestResultFailureTaskWithNoMessageTestFixture + { + Task task; + + [TestFixtureSetUp] + public void SetUpFixture() + { + ResourceManager.Initialize(); + } + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyNamespace.MyTests"); + testResult.ResultType = TestResultType.Failure; + task = TestResultTask.Create(testResult, null); + } + + [Test] + public void TaskMessageEqualsIsTakenFromStringResource() + { + Assert.AreEqual("Test case 'MyNamespace.MyTests' failed.", task.Description); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs new file mode 100644 index 0000000000..8e5e765706 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskTestFixture.cs @@ -0,0 +1,67 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class TestResultIgnoreTaskTestFixture + { + Task task; + + [SetUp] + public void Init() + { + string className = "MyNamespace.MyTests"; + TestProject testProject = + TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod(className, "MyTestMethod"); + + TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod"); + testResult.ResultType = TestResultType.Ignored; + testResult.Message = "Test ignored"; + + task = TestResultTask.Create(testResult, testProject); + } + + [Test] + public void TaskTypeIsWarning() + { + Assert.AreEqual(TaskType.Warning, task.TaskType); + } + + [Test] + public void TaskMessageEqualsTestResultMessage() + { + Assert.AreEqual("Test ignored", task.Description); + } + + [Test] + public void TaskFileNameMatchesCompilationUnitFileName() + { + string expectedFileName = @"c:\projects\tests\MyTests.cs"; + Assert.AreEqual(expectedFileName, task.FileName.ToString()); + } + + [Test] + public void TaskLineNumberIs4SameAsMethod() + { + Assert.AreEqual(4, task.Line); + } + + [Test] + public void TaskColumnNumberIs19SameAsMethod() + { + Assert.AreEqual(19, task.Column); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs new file mode 100644 index 0000000000..04dd189cc0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithNoMessageTestFixture.cs @@ -0,0 +1,43 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Resources; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class TestResultIgnoreTaskWithNoMessageTestFixture + { + Task task; + + [TestFixtureSetUp] + public void SetUpFixture() + { + ResourceManager rm = new ResourceManager("UnitTesting.Tests.Strings", GetType().Assembly); + ResourceService.RegisterNeutralStrings(rm); + } + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyNamespace.MyTests"); + testResult.ResultType = TestResultType.Ignored; + task = TestResultTask.Create(testResult, null); + } + + [Test] + public void TaskMessageEqualsIsTakenFromStringResource() + { + Assert.AreEqual("Test case 'MyNamespace.MyTests' was not executed.", task.Description); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs new file mode 100644 index 0000000000..0af7a95297 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture.cs @@ -0,0 +1,69 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class TestResultIgnoreTaskWithoutMatchingTestMethodTestFixture + { + Task task; + + [SetUp] + public void Init() + { + MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks(); + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + TestClass testClass = new TestClass(c, testFrameworks); + + TestProject testProject = new TestProject(c.Project, c.ProjectContent, testFrameworks); + testProject.TestClasses.Add(testClass); + + TestResult testResult = new TestResult("MyNamespace.MyTests.MyTestMethod"); + testResult.ResultType = TestResultType.Ignored; + testResult.Message = "Test ignored"; + + task = TestResultTask.Create(testResult, testProject); + } + + [Test] + public void TaskTypeIsWarning() + { + Assert.AreEqual(TaskType.Warning, task.TaskType); + } + + [Test] + public void TaskMessageEqualsTestResultMessage() + { + Assert.AreEqual("Test ignored", task.Description); + } + + [Test] + public void TaskFileNameIsNull() + { + Assert.IsNull(task.FileName); + } + + [Test] + public void TaskLineNumberIsZero() + { + Assert.AreEqual(0, task.Line); + } + + [Test] + public void TaskColumnNumberIsZero() + { + Assert.AreEqual(0, task.Column); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs new file mode 100644 index 0000000000..3a7affb3e5 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TestableConditionTests.cs @@ -0,0 +1,186 @@ +// +// +// +// +// $Revision$ +// + +using ICSharpCode.SharpDevelop.Bookmarks; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui.ClassBrowser; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using System; +using System.Collections.Generic; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Tree +{ + [TestFixture] + public class TestableConditionTests + { + TestableCondition testableCondition; + MockRegisteredTestFrameworks testFrameworks; + + [TestFixtureSetUp] + public void SetUpFixture() + { + ResourceManager.Initialize(); + } + + [SetUp] + public void Init() + { + testFrameworks = new MockRegisteredTestFrameworks(); + testableCondition = new TestableCondition(testFrameworks); + } + + [Test] + public void GetMemberFromNullOwner() + { + Assert.IsNull(TestableCondition.GetMember(null)); + } + + [Test] + public void GetClassFromNullOwner() + { + Assert.IsNull(TestableCondition.GetClass(null)); + } + + [Test] + public void GetProjectFromNullOwner() + { + Assert.IsNull(TestableCondition.GetProject(null)); + } + + [Test] + public void GetNamespaceFromNullOwner() + { + Assert.IsNull(TestableCondition.GetNamespace(null)); + } + + [Test] + public void IsValidFromNullOwner() + { + Assert.IsFalse(testableCondition.IsValid(null, null)); + } + + [Test] + public void GetMemberFromTreeView() + { + MockTestTreeView mockTreeView = new MockTestTreeView(); + MockMember mockMember = new MockMember(); + mockTreeView.SelectedMethod = mockMember; + + Assert.IsTrue(Object.ReferenceEquals(mockMember, TestableCondition.GetMember(mockTreeView))); + } + + [Test] + public void GetClassFromTreeView() + { + MockTestTreeView mockTreeView = new MockTestTreeView(); + MockClass mockClass = new MockClass(); + mockTreeView.SelectedClass = mockClass; + + Assert.IsTrue(Object.ReferenceEquals(mockClass, TestableCondition.GetClass(mockTreeView))); + } + + [Test] + public void GetProjectFromTreeView() + { + MockTestTreeView mockTreeView = new MockTestTreeView(); + MSBuildBasedProject project = new MockCSharpProject(); + mockTreeView.SelectedProject = project; + + Assert.IsTrue(Object.ReferenceEquals(project, TestableCondition.GetProject(mockTreeView))); + } + + [Test] + public void GetNamespaceFromTreeView() + { + MockTestTreeView mockTreeView = new MockTestTreeView(); + MSBuildBasedProject project = new MockCSharpProject(); + mockTreeView.SelectedProject = project; + mockTreeView.SelectedNamespace = "MyProject.Tests"; + + Assert.AreEqual("MyProject.Tests", TestableCondition.GetNamespace(mockTreeView)); + } + + [Test] + public void GetMemberFromMemberNode() + { + MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); + MockMemberNode memberNode = new MockMemberNode(mockMethod); + + Assert.IsTrue(Object.ReferenceEquals(mockMethod, TestableCondition.GetMember(memberNode))); + } + + [Test] + public void GetProjectFromMemberNode() + { + MSBuildBasedProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + MockClass mockClass = new MockClass(mockProjectContent); + MockMethod mockMethod = new MockMethod(mockClass); + MockMemberNode memberNode = new MockMemberNode(mockMethod); + + Assert.IsTrue(Object.ReferenceEquals(project, TestableCondition.GetProject(memberNode))); + } + + [Test] + public void GetClassFromClassNode() + { + MockClass mockClass = new MockClass(new MockProjectContent()); + ClassNode classNode = new ClassNode(null, mockClass); + + Assert.IsTrue(Object.ReferenceEquals(mockClass, TestableCondition.GetClass(classNode))); + } + + [Test] + public void GetProjectFromClassNode() + { + MSBuildBasedProject project = new MockCSharpProject(); + MockProjectContent mockProjectContent = new MockProjectContent(); + mockProjectContent.Project = project; + MockClass mockClass = new MockClass(mockProjectContent); + ClassNode classNode = new ClassNode(project, mockClass); + + Assert.IsTrue(Object.ReferenceEquals(project, TestableCondition.GetProject(classNode))); + } + + [Test] + public void GetMemberFromClassMemberBookmark() + { + MockMethod mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); + mockMethod.Region = new DomRegion(1, 1); + ClassMemberBookmark bookmark = new ClassMemberBookmark(mockMethod); + + Assert.IsTrue(Object.ReferenceEquals(mockMethod, TestableCondition.GetMember(bookmark))); + } + + [Test] + public void GetClassFromClassBookmark() + { + MockClass mockClass = new MockClass(); + mockClass.Region = new DomRegion(1, 1); + ClassBookmark bookmark = new ClassBookmark(mockClass); + + Assert.IsTrue(Object.ReferenceEquals(mockClass, TestableCondition.GetClass(bookmark))); + } + + /// + /// Tests references to class.ProjectContent when + /// it is null. + /// + [Test] + public void GetProjectWhenProjectContentIsNull() + { + MockClass mockClass = new MockClass(new MockProjectContent()); + ClassNode classNode = new ClassNode(null, mockClass); + + Assert.IsNull(TestableCondition.GetProject(classNode)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeContextMenuTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeContextMenuTestFixture.cs index 9beb413944..3ad392ade6 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeContextMenuTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeContextMenuTestFixture.cs @@ -34,7 +34,7 @@ namespace UnitTesting.Tests.Tree treeView.ContextMenuStrip = menuStrip; // Add a root node to the tree. - TestProject project = new TestProject(new MockCSharpProject(), new MockProjectContent()); + TestProject project = new TestProject(new MockCSharpProject(), new MockProjectContent(), new MockTestFrameworksWithNUnitFrameworkSupport()); TestProjectTreeNode node = new TestProjectTreeNode(project); node.AddTo(treeView); diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs index 2c25712b89..e0a0359bdd 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TreeNodeSortingTestFixture.cs @@ -33,6 +33,7 @@ namespace UnitTesting.Tests.Tree TestClassTreeNode testFixtureNode; MockProjectContent projectContent; TestProject testProject; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void Init() @@ -54,13 +55,12 @@ namespace UnitTesting.Tests.Tree // Add two methods to the test class only // one of which has test attributes. - MockMethod testMethod = new MockMethod("NameExists"); + MockMethod testMethod = new MockMethod(testClass.Class, "NameExists"); testMethod.Attributes.Add(new MockAttribute("Test")); - testMethod.DeclaringType = testClass.Class; testClass.Class.Methods.Add(testMethod); - - // Init mock project content to be returned. - treeView = new DummyParserServiceTestTreeView(); + + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + treeView = new DummyParserServiceTestTreeView(testFrameworks); treeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. @@ -224,9 +224,8 @@ namespace UnitTesting.Tests.Tree public void NewClassMethodAdded() { MockClass c = (MockClass)testFixtureNode.Class; - MockMethod method = new MockMethod("Apple"); + MockMethod method = new MockMethod(c, "Apple"); method.Attributes.Add(new MockAttribute("Test")); - method.DeclaringType = c; c.SetCompoundClass(c); c.Methods.Add(method); @@ -247,10 +246,9 @@ namespace UnitTesting.Tests.Tree /// TestClass CreateTestClass(string name) { - MockClass c = new MockClass(name); + MockClass c = new MockClass(projectContent, name); c.Attributes.Add(new MockAttribute("TestFixture")); - c.ProjectContent = projectContent; - return new TestClass(c); + return new TestClass(c, testFrameworks); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs index 64e0a28124..67dc974cf3 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Tree/TwoTestClassesInDifferentNamespacesTestFixture.cs @@ -36,11 +36,11 @@ namespace UnitTesting.Tests.Tree ExtTreeNode projectNamespaceNode; TestProject testProject; MockProjectContent projectContent; + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; [SetUp] public void SetUp() { - // Create solution. solution = new Solution(); // Create a project to display in the test tree view. @@ -52,18 +52,16 @@ namespace UnitTesting.Tests.Tree // Add a test class with a TestFixture attributes. projectContent = new MockProjectContent(); projectContent.Language = LanguageProperties.None; - testClass1 = new MockClass("Project.Tests.MyTestFixture"); + testClass1 = new MockClass(projectContent, "Project.Tests.MyTestFixture"); testClass1.Attributes.Add(new MockAttribute("TestFixture")); - testClass1.ProjectContent = projectContent; projectContent.Classes.Add(testClass1); - testClass2 = new MockClass("Project.MyTestFixture"); + testClass2 = new MockClass(projectContent, "Project.MyTestFixture"); testClass2.Attributes.Add(new MockAttribute("TestFixture")); - testClass2.ProjectContent = projectContent; projectContent.Classes.Add(testClass2); - // Init mock project content to be returned. - dummyTreeView = new DummyParserServiceTestTreeView(); + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + dummyTreeView = new DummyParserServiceTestTreeView(testFrameworks); dummyTreeView.ProjectContentForProject = projectContent; // Load the projects into the test tree view. @@ -128,7 +126,7 @@ namespace UnitTesting.Tests.Tree TestClass testClass2 = testProject.TestClasses["Project.MyTestFixture"]; testClass2.Result = TestResultType.Success; - + ExpandRootNode(); Assert.AreEqual(TestTreeViewImageListIndex.TestFailed, (TestTreeViewImageListIndex)projectNamespaceNode.ImageIndex); } @@ -139,10 +137,9 @@ namespace UnitTesting.Tests.Tree ExtTreeNode projectNamespaceNode = ExpandProjectNamespaceNode(); ExtTreeNode testsNamespaceNode = ExpandTestsNamespaceNode(); - MockClass mockClass = new MockClass("Project.Tests.MyNewTestFixture"); + MockClass mockClass = new MockClass(projectContent, "Project.Tests.MyNewTestFixture"); mockClass.Attributes.Add(new MockAttribute("TestFixture")); - mockClass.ProjectContent = projectContent; - TestClass newTestClass = new TestClass(mockClass); + TestClass newTestClass = new TestClass(mockClass, testFrameworks); testProject.TestClasses.Add(newTestClass); ExtTreeNode newTestClassNode = null; @@ -153,7 +150,7 @@ namespace UnitTesting.Tests.Tree } } newTestClass.Result = TestResultType.Failure; - + // New test class node should be added to the test namespace node. Assert.AreEqual(2, testsNamespaceNode.Nodes.Count); Assert.IsNotNull(newTestClassNode); @@ -177,7 +174,7 @@ namespace UnitTesting.Tests.Tree ExtTreeNode projectNamespaceNode = ExpandProjectNamespaceNode(); ExtTreeNode testsNamespaceNode = ExpandTestsNamespaceNode(); - + // Reset the new TestClass result after it was modified // in the AddNewClass call. TestClass newTestClass = testProject.TestClasses["Project.Tests.MyNewTestFixture"]; @@ -195,14 +192,14 @@ namespace UnitTesting.Tests.Tree } } testClass.Result = TestResultType.Failure; - + Assert.AreEqual(1, testsNamespaceNode.Nodes.Count); Assert.IsNull(testClassNode); // Make sure the namespace node image index is NOT affected by the // test class just removed. Assert.AreEqual(TestTreeViewImageListIndex.TestNotRun, (TestTreeViewImageListIndex)testsNamespaceNode.SelectedImageIndex); - + // Check that the test class does not affect the project namespace node // image index either. Assert.AreEqual(TestTreeViewImageListIndex.TestNotRun, (TestTreeViewImageListIndex)projectNamespaceNode.ImageIndex); @@ -230,7 +227,7 @@ namespace UnitTesting.Tests.Tree } } Assert.IsNull(testClassNode); - + // Project namespace node should only have one child node. Assert.AreEqual(1, projectNamespaceNode.Nodes.Count); Assert.AreEqual("MyTestFixture", projectNamespaceNode.Nodes[0].Text); diff --git a/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj b/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj index 029481fdc3..20212171c7 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj +++ b/src/AddIns/Analysis/UnitTesting/Test/UnitTesting.Tests.csproj @@ -60,7 +60,25 @@ - + + + + + + + + + + + + + + + + + + + @@ -71,25 +89,131 @@ + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SharpDevelop.exe Always @@ -99,10 +223,7 @@ - - - @@ -112,8 +233,6 @@ - - @@ -128,6 +247,7 @@ + {1F261725-6318-4434-A1B1-6C70CE4CD324} UnitTesting @@ -144,6 +264,7 @@ {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} ICSharpCode.SharpDevelop.Dom + {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs new file mode 100644 index 0000000000..cc42140a5b --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestCommand.cs @@ -0,0 +1,112 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class DerivedRunTestCommand : AbstractRunTestCommand + { + bool onBeforeRunTestsMethodCalled; + bool onAfterRunTestsMethodCalled; + AbstractRunTestCommand runningTestCommandWhenOnBeforeRunCalled; + bool runningTestWhenOnBeforeRunCalled; + bool onStopMethodCalled; + List helpers = new List(); + List testRunnersCreated = new List(); + + public DerivedRunTestCommand(IRunTestCommandContext context) + : base(context) + { + } + + public bool IsOnBeforeRunTestsMethodCalled { + get { return onBeforeRunTestsMethodCalled; } + } + + public void CallOnBeforeRunTestsMethod() + { + OnBeforeRunTests(); + } + + protected override void OnBeforeRunTests() + { + onBeforeRunTestsMethodCalled = true; + runningTestCommandWhenOnBeforeRunCalled = AbstractRunTestCommand.RunningTestCommand; + runningTestWhenOnBeforeRunCalled = AbstractRunTestCommand.IsRunningTest; + } + + protected override ITestRunner CreateTestRunner(IProject project) + { + MockTestRunner testRunner = new MockTestRunner(); + testRunnersCreated.Add(testRunner); + return testRunner; + } + + public List TestRunnersCreated { + get { return testRunnersCreated; } + } + + protected override void RunTests(NUnitConsoleApplication helper) + { + helpers.Add(helper); + } + + public List Helpers { + get { return helpers; } + } + + public AbstractRunTestCommand RunningTestCommandPropertyWhenOnBeforeRunCalled { + get { return runningTestCommandWhenOnBeforeRunCalled; } + } + + public bool IsRunningTestPropertyWhenOnBeforeRunCalled { + get { return runningTestWhenOnBeforeRunCalled; } + } + + public bool IsOnStopMethodCalled { + get { return onStopMethodCalled; } + } + + protected override void OnStop() + { + onStopMethodCalled = true; + } + + public Action ShowResultAction { + get { return ShowResult; } + } + + public void CallTestsCompleted() + { + base.TestRunCompleted(); + } + + public bool IsOnAfterRunTestsMethodCalled { + get { return onAfterRunTestsMethodCalled; } + } + + public void CallOnAfterRunTestsMethod() + { + OnAfterRunTests(); + } + + protected override void OnAfterRunTests() + { + onAfterRunTestsMethodCalled = true; + } + + public ITestRunner CallCreateTestRunner(IProject project) + { + return CreateTestRunner(project); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestInPadCommand.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestInPadCommand.cs new file mode 100644 index 0000000000..27a7f9310f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestInPadCommand.cs @@ -0,0 +1,27 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class DerivedRunTestInPadCommand : RunTestInPadCommand + { + public DerivedRunTestInPadCommand(IRunTestCommandContext context) + : base(context) + { + } + + public Action GetCallRunTestCompletedAction() + { + Action action = base.TestRunCompleted; + return action; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestWithDebuggerCommand.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestWithDebuggerCommand.cs new file mode 100644 index 0000000000..b55a8b3e93 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedRunTestWithDebuggerCommand.cs @@ -0,0 +1,26 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class DerivedRunTestWithDebuggerCommand : RunTestWithDebuggerCommand + { + public DerivedRunTestWithDebuggerCommand(IRunTestCommandContext context) + : base(context) + { + } + + public Action GetCallRunTestCompletedAction() + { + Action action = base.TestRunCompleted; + return action; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs index 767bdb125f..345988003c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedTestTreeView.cs @@ -17,6 +17,11 @@ namespace UnitTesting.Tests.Utils /// public class DerivedTestTreeView : TestTreeView { + public DerivedTestTreeView() + : base(new MockTestFrameworksWithNUnitFrameworkSupport()) + { + } + /// /// Calls the base class's OnBeforeSelect method. /// diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs index 57d2ceb250..480f442d06 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DerivedUnitTestsPad.cs @@ -29,11 +29,13 @@ namespace UnitTesting.Tests.Utils DummyParserServiceTestTreeView treeView = new DummyParserServiceTestTreeView(); public DerivedUnitTestsPad(Solution openSolution) + : base(new MockTestFrameworksWithNUnitFrameworkSupport()) { this.openSolution = openSolution; } public DerivedUnitTestsPad() + : this(null) { } @@ -42,9 +44,7 @@ namespace UnitTesting.Tests.Utils /// derived test tree view. /// public MockProjectContent ProjectContent { - get { - return projectContent; - } + get { return projectContent; } set { projectContent = value; treeView.ProjectContentForProject = projectContent; @@ -52,15 +52,11 @@ namespace UnitTesting.Tests.Utils } public bool GetOpenSolutionCalled { - get { - return getOpenSolutionCalled; - } + get { return getOpenSolutionCalled; } } public bool IsParserLoadingSolutionCalled { - get { - return isParserLoadingSolutionCalled; - } + get { return isParserLoadingSolutionCalled; } } /// @@ -69,9 +65,7 @@ namespace UnitTesting.Tests.Utils /// called. This ensures we do not miss this event. /// public bool LoadSolutionProjectsThreadEndedHandled { - get { - return loadSolutionProjectsThreadEndedHandled; - } + get { return loadSolutionProjectsThreadEndedHandled; } } public void CallSolutionLoaded(Solution solution) @@ -133,7 +127,7 @@ namespace UnitTesting.Tests.Utils /// Returns a dummy tree view where we can mock the /// IProjectContent that will be used by the TestTreeView. /// - protected override TestTreeView CreateTestTreeView() + protected override TestTreeView CreateTestTreeView(IRegisteredTestFrameworks testFrameworks) { return treeView; } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs index 39f5544c88..ec5dcd7673 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/DummyParserServiceTestTreeView.cs @@ -20,17 +20,23 @@ namespace UnitTesting.Tests.Utils { IProjectContent projectContent; + public DummyParserServiceTestTreeView(IRegisteredTestFrameworks testFrameworks) + : base(testFrameworks) + { + } + + public DummyParserServiceTestTreeView() + : this(new MockTestFrameworksWithNUnitFrameworkSupport()) + { + } + /// /// Gets or sets the project content that will be returned from the /// GetProjectContent method. /// public IProjectContent ProjectContentForProject { - get { - return projectContent; - } - set { - projectContent = value; - } + get { return projectContent; } + set { projectContent = value; } } public override IProjectContent GetProjectContent(IProject project) diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/JumpedToFile.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/JumpedToFile.cs new file mode 100644 index 0000000000..d251432cf5 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/JumpedToFile.cs @@ -0,0 +1,47 @@ +// +// +// +// +// $Revision$ +// + + +using System; + +namespace UnitTesting.Tests.Utils +{ + public class JumpedToFile + { + string fileName = String.Empty; + int line = -2; + int col = -2; + + public JumpedToFile(string fileName, int line, int col) + { + this.fileName = fileName; + this.line = line; + this.col = col; + } + + public override string ToString() + { + return String.Format("File: {0} Line: {1} Col: {2}", fileName, line, col); + } + + public override bool Equals(object obj) + { + JumpedToFile rhs = obj as JumpedToFile; + if (rhs != null) { + return (fileName == rhs.fileName) && + (line == rhs.line) && + (col == rhs.col); + } + return false; + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs new file mode 100644 index 0000000000..61cf7e1bbf --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockAddInTree.cs @@ -0,0 +1,37 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockAddInTree : IAddInTree + { + Dictionary treeItems = new Dictionary(); + + public MockAddInTree() + { + } + + public List BuildItems(string path, object caller) + { + object obj; + if (treeItems.TryGetValue(path, out obj)) { + return obj as List; + } + throw new TreePathNotFoundException(path); + } + + public void AddItems(string path, List items) + { + treeItems.Add(path, items); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildOptions.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildOptions.cs new file mode 100644 index 0000000000..4f8cf8d75e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildOptions.cs @@ -0,0 +1,22 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockBuildOptions : IBuildOptions + { + bool showErrorListAfterBuild = true; + + public bool ShowErrorListAfterBuild { + get { return showErrorListAfterBuild; } + set { showErrorListAfterBuild = value; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildProjectBeforeTestRun.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildProjectBeforeTestRun.cs new file mode 100644 index 0000000000..5f02818ca4 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildProjectBeforeTestRun.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockBuildProjectBeforeTestRun : BuildProjectBeforeTestRun + { + IProject project; + bool runMethodCalled; + + public MockBuildProjectBeforeTestRun() + : base(null) + { + } + + public IProject Project { + get { return project; } + set { project = value; } + } + + public void FireBuildCompleteEvent() + { + base.OnBuildComplete(new EventArgs()); + } + + public override void Run() + { + runMethodCalled = true; + LastBuildResults = new BuildResults(); + } + + public bool IsRunMethodCalled { + get { return runMethodCalled; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildProjectFactory.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildProjectFactory.cs new file mode 100644 index 0000000000..5f922b745d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockBuildProjectFactory.cs @@ -0,0 +1,43 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockBuildProjectFactory : IBuildProjectFactory + { + List buildProjectInstances = new List(); + + public BuildProjectBeforeTestRun CreateBuildProjectBeforeTestRun(IProject project) + { + MockBuildProjectBeforeTestRun buildProject = RemoveBuildProjectInstance(); + if (buildProject != null) { + buildProject.Project = project; + } + return buildProject; + } + + MockBuildProjectBeforeTestRun RemoveBuildProjectInstance() + { + if (buildProjectInstances.Count > 0) { + MockBuildProjectBeforeTestRun buildProject = buildProjectInstances[0]; + buildProjectInstances.RemoveAt(0); + return buildProject; + } + return null; + } + + public void AddBuildProjectBeforeTestRun(MockBuildProjectBeforeTestRun buildBeforeTestRun) + { + buildProjectInstances.Add(buildBeforeTestRun); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs index 25af46775b..3beebe6c3a 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockCSharpProject.cs @@ -5,34 +5,48 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.Internal.Templates; using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; namespace UnitTesting.Tests.Utils { public class MockCSharpProject : CompilableProject { + bool saved; + public MockCSharpProject() - : this(new Solution(), "Dummy") + : this(new Solution(), "MyTests") { } public MockCSharpProject(Solution solution, string name) : base(new ProjectCreateInformation { - Solution = solution, - ProjectName = name, - OutputProjectFileName = "c:\\temp\\" + name + ".csproj" - }) + Solution = solution, + ProjectName = name, + TargetFramework = "v4.0", + OutputProjectFileName = "c:\\projects\\" + name + "\\" + name + ".csproj" + }) { + OutputType = OutputType.Library; } public override string Language { get { return "C#"; } } - public override ICSharpCode.SharpDevelop.Dom.LanguageProperties LanguageProperties { - get { return ICSharpCode.SharpDevelop.Dom.LanguageProperties.CSharp; } + public override LanguageProperties LanguageProperties { + get { return LanguageProperties.CSharp; } + } + + public bool IsSaved { + get { return saved; } + } + + public override void Save(string fileName) + { + saved = true; } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs index ec4513653b..02f9752ed3 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockClass.cs @@ -6,397 +6,131 @@ // using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; using System; using System.Collections.Generic; namespace UnitTesting.Tests.Utils { - public class MockClass : IClass + public class MockClass : DefaultClass { - IProjectContent projectContent; - DomRegion region = DomRegion.Empty; - IList attributes = new List(); - IList methods = new List(); - IList innerClasses = new List(); - string fullyQualifiedName = String.Empty; - string name = String.Empty; - string ns = String.Empty; + string dotNetName; IClass compoundClass; - IClass baseClass; - string dotNetName = String.Empty; - IClass declaringType; public MockClass() + : this(String.Empty) { } - public MockClass(string fullyQualifiedName) : this(fullyQualifiedName, fullyQualifiedName) + public MockClass(IProjectContent projectContent) + : this(projectContent, String.Empty) { } - public MockClass(string fullyQualifiedName, string dotNetName) + public MockClass(IProjectContent projectContent, string fullyQualifiedName) + : this(projectContent, fullyQualifiedName, null) { - FullyQualifiedName = fullyQualifiedName; - this.dotNetName = dotNetName; } - public override string ToString() + public MockClass(string fullyQualifiedName) + : this(fullyQualifiedName, fullyQualifiedName) { - return dotNetName; - } - - public string FullyQualifiedName { - get { return fullyQualifiedName; } - set { - fullyQualifiedName = value; - int index = fullyQualifiedName.LastIndexOf('.'); - if (index > 0) { - name = fullyQualifiedName.Substring(index + 1); - ns = fullyQualifiedName.Substring(0, index); - } else { - name = fullyQualifiedName; - } - } - } - - public string Name { - get { return name; } - set { name = value; } - } - - public string Namespace { - get { return ns; } - set { ns = value; } - } - - public ClassType ClassType { - get { return ClassType.Class; } - } - - public IProjectContent ProjectContent { - get { return projectContent; } - set { projectContent = value; } - } - - public DomRegion Region { - get { return region; } - set { region = value; } - } - - public IList Methods { - get { return methods; } - } - - public IClass BaseClass { - get { return baseClass; } - set { baseClass = value; } - } - - public ModifierEnum Modifiers { - get { return ModifierEnum.None; } - set { } } - public IList Attributes { - get { return attributes; } + public MockClass(string fullyQualifiedName, string dotNetName) + : this(fullyQualifiedName, dotNetName, null) + { } - public IClass GetCompoundClass() + public MockClass(string fullyQualifiedName, string dotNetName, IClass declaringType) + : this(new MockProjectContent(), fullyQualifiedName, dotNetName, declaringType) { - return compoundClass; } - public void SetCompoundClass(IClass c) + public MockClass(IProjectContent projectContent, string fullyQualifiedName, IClass declaringType) + : this(projectContent, fullyQualifiedName, fullyQualifiedName, declaringType) { - compoundClass = c; } - public IReturnType DefaultReturnType { - get { - throw new NotImplementedException(); + public MockClass(IProjectContent projectContent, string fullyQualifiedName, string dotNetName, IClass declaringType) + : base(new DefaultCompilationUnit(projectContent), declaringType) + { + this.FullyQualifiedName = fullyQualifiedName; + this.dotNetName = dotNetName; + + if (declaringType != null) { + declaringType.InnerClasses.Add(this); } } - public string DotNetName { + public override string DotNetName { get { return dotNetName; } } - public ICompilationUnit CompilationUnit { - get { - throw new NotImplementedException(); - } - } - - public IUsingScope UsingScope { - get { - throw new NotImplementedException(); - } - } - - public DomRegion BodyRegion { - get { - throw new NotImplementedException(); - } - } - - public IList BaseTypes { - get { - throw new NotImplementedException(); - } - } - - public IList InnerClasses { - get { return innerClasses; } - } - - public IList Fields { - get { - throw new NotImplementedException(); - } - } - - public IList Properties { - get { - throw new NotImplementedException(); - } - } - - public IList Events { - get { - throw new NotImplementedException(); - } - } - - public IList TypeParameters { - get { - throw new NotImplementedException(); - } - } - - public IEnumerable ClassInheritanceTree { - get { - throw new NotImplementedException(); - } - } - - public IEnumerable ClassInheritanceTreeClassesOnly { - get { - throw new NotImplementedException(); - } - } - - public IReturnType BaseType { - get { - throw new NotImplementedException(); - } - } - - public bool HasPublicOrInternalStaticMembers { - get { - throw new NotImplementedException(); - } - } - - public bool HasExtensionMethods { - get { - throw new NotImplementedException(); - } - } - - public bool IsPartial { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IClass DeclaringType { - get { return declaringType; } - set { declaringType = value; } - } - - public string Documentation { - get { - throw new NotImplementedException(); - } - } - - public bool IsAbstract { - get { - throw new NotImplementedException(); - } - } - - public bool IsSealed { - get { - throw new NotImplementedException(); - } - } - - public bool IsStatic { - get { - throw new NotImplementedException(); - } - } - - public bool IsConst { - get { - throw new NotImplementedException(); - } - } - - public bool IsVirtual { - get { - throw new NotImplementedException(); - } - } - - public bool IsPublic { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtected { - get { - throw new NotImplementedException(); - } - } - - public bool IsPrivate { - get { - throw new NotImplementedException(); - } - } - - public bool IsInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsReadonly { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtectedAndInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtectedOrInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsOverride { - get { - throw new NotImplementedException(); - } - } - - public bool IsOverridable { - get { - throw new NotImplementedException(); - } - } - - public bool IsNew { - get { - throw new NotImplementedException(); - } - } - - public bool IsSynthetic { - get { - throw new NotImplementedException(); - } - } - - public object UserData { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public bool IsFrozen { - get { - throw new NotImplementedException(); - } - } - - public IReturnType GetBaseType(int index) + public void SetDotNetName(string name) { - throw new NotImplementedException(); + dotNetName = name; } - public IClass GetInnermostClass(int caretLine, int caretColumn) - { - throw new NotImplementedException(); + public MockProjectContent MockProjectContent { + get { return ProjectContent as MockProjectContent; } } - public List GetAccessibleTypes(IClass callingClass) - { - throw new NotImplementedException(); + public IProject Project { + get { return ProjectContent.Project as IProject; } } - public IMember SearchMember(string memberName, LanguageProperties language) + public static MockClass CreateMockClassWithoutAnyAttributes() { - throw new NotImplementedException(); + return CreateMockClassWithAttributes(new MockAttribute[0]); } - public bool IsTypeInInheritanceTree(IClass possibleBaseClass) + public static MockClass CreateMockClassWithAttributes(IList attributes) { - throw new NotImplementedException(); + MockClass mockClass = new MockClass(); + mockClass.MockProjectContent.Project = new MockCSharpProject(); + mockClass.MockProjectContent.Classes.Add(mockClass); + + foreach (MockAttribute attribute in attributes) { + mockClass.Attributes.Add(attribute); + } + return mockClass; } - public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree) + public static MockClass CreateMockClassWithAttribute(MockAttribute attribute) { - throw new NotImplementedException(); + List attributes = new List(); + attributes.Add(attribute); + + return CreateMockClassWithAttributes(attributes); } - public void Freeze() + public static MockClass CreateClassWithBaseType(string baseTypeName) { - throw new NotImplementedException(); + MockClass baseType = MockClass.CreateMockClassWithoutAnyAttributes(); + baseType.FullyQualifiedName = baseTypeName; + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.BaseTypes.Add(new DefaultReturnType(baseType)); + return c; } - public int CompareTo(object obj) + public void SetCompoundClass(IClass c) { - throw new NotImplementedException(); + this.compoundClass = c; } - public bool HasCompoundClass { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IEnumerable AllMembers { - get { - throw new NotImplementedException(); + protected override IReturnType CreateDefaultReturnType() + { + if (compoundClass != null) { + return new DefaultReturnType(compoundClass); } + return base.CreateDefaultReturnType(); } - public EntityType EntityType { - get { return EntityType.Class; } - } - - public bool AddDefaultConstructorIfRequired { - get { - throw new NotImplementedException(); - } + public void AddBaseClass(IClass baseClass) + { + DefaultReturnType returnType = new DefaultReturnType(baseClass); + BaseTypes.Add(returnType); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs new file mode 100644 index 0000000000..ba0b420292 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebugger.cs @@ -0,0 +1,175 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.SharpDevelop.Debugging; +using ICSharpCode.SharpDevelop.Project; + +namespace UnitTesting.Tests.Utils +{ + public class MockDebugger : IDebugger + { + bool debugging; + bool stopCalled; + ProcessStartInfo processStartInfo; + Exception exceptionToThrowOnStart; + + public event EventHandler DebugStarting; + + protected virtual void OnDebugStarting(EventArgs e) + { + if (DebugStarting != null) { + DebugStarting(this, e); + } + } + + public event EventHandler DebugStarted; + + protected virtual void OnDebugStarted(EventArgs e) + { + if (DebugStarted != null) { + DebugStarted(this, e); + } + } + + public event EventHandler IsProcessRunningChanged; + + protected virtual void OnIsProcessRunningChanged(EventArgs e) + { + if (IsProcessRunningChanged != null) { + IsProcessRunningChanged(this, e); + } + } + + public event EventHandler DebugStopped; + + public void FireDebugStoppedEvent() + { + OnDebugStopped(new EventArgs()); + } + + protected virtual void OnDebugStopped(EventArgs e) + { + if (DebugStopped != null) { + DebugStopped(this, e); + } + } + + public bool IsDebugging { + get { return debugging; } + set { debugging = value; } + } + + public bool IsProcessRunning { + get { + throw new NotImplementedException(); + } + } + + public bool CanDebug(IProject project) + { + throw new NotImplementedException(); + } + + public void Start(ProcessStartInfo processStartInfo) + { + this.processStartInfo = processStartInfo; + if (exceptionToThrowOnStart != null) { + throw exceptionToThrowOnStart; + } + } + + public ProcessStartInfo ProcessStartInfo { + get { return processStartInfo; } + } + + public Exception ThrowExceptionOnStart { + get { return exceptionToThrowOnStart; } + set { exceptionToThrowOnStart = value; } + } + + public void StartWithoutDebugging(ProcessStartInfo processStartInfo) + { + throw new NotImplementedException(); + } + + public void Stop() + { + stopCalled = true; + } + + public bool IsStopCalled { + get { return stopCalled; } + } + + public void Break() + { + throw new NotImplementedException(); + } + + public void Continue() + { + throw new NotImplementedException(); + } + + public void StepInto() + { + throw new NotImplementedException(); + } + + public void StepOver() + { + throw new NotImplementedException(); + } + + public void StepOut() + { + throw new NotImplementedException(); + } + + public void ShowAttachDialog() + { + throw new NotImplementedException(); + } + + public void Attach(Process process) + { + throw new NotImplementedException(); + } + + public void Detach() + { + throw new NotImplementedException(); + } + + public string GetValueAsString(string variable) + { + throw new NotImplementedException(); + } + + public object GetTooltipControl(string variable) + { + throw new NotImplementedException(); + } + + public bool CanSetInstructionPointer(string filename, int line, int column) + { + throw new NotImplementedException(); + } + + public bool SetInstructionPointer(string filename, int line, int column) + { + throw new NotImplementedException(); + } + + public void Dispose() + { + throw new NotImplementedException(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebuggerService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebuggerService.cs new file mode 100644 index 0000000000..564ac1152a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockDebuggerService.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Debugging; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockDebuggerService : IUnitTestDebuggerService + { + bool debuggerLoaded; + MockDebugger debugger = new MockDebugger(); + + public bool IsDebuggerLoaded { + get { return debuggerLoaded; } + set { debuggerLoaded = value; } + } + + public IDebugger CurrentDebugger { + get { return debugger; } + } + + public MockDebugger MockDebugger { + get { return debugger; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs new file mode 100644 index 0000000000..ad6176b443 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockFileService.cs @@ -0,0 +1,37 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockFileService : IUnitTestFileService + { + string fileOpened; + FilePosition? filePositionJumpedTo; + + public string FileOpened { + get { return fileOpened; } + } + + public FilePosition? FilePositionJumpedTo { + get { return filePositionJumpedTo; } + } + + public void OpenFile(string fileName) + { + fileOpened = fileName; + } + + public void JumpToFilePosition(string fileName, int line, int column) + { + filePositionJumpedTo = new FilePosition(fileName, line, column); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs new file mode 100644 index 0000000000..8ce577054c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMessageService.cs @@ -0,0 +1,39 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockMessageService : IUnitTestMessageService + { + string question; + string caption; + bool returnValue; + + public bool AskQuestionReturnValue { + get { return returnValue; } + set { returnValue = value; } + } + + public bool AskQuestion(string question, string caption) + { + this.question = question; + this.caption = caption; + return returnValue; + } + + public string Question { + get { return question; } + } + + public string Caption { + get { return caption; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs index 73ea1ed365..d2ba211307 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockMethod.cs @@ -5,323 +5,62 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.Dom; using System; using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; namespace UnitTesting.Tests.Utils { - public class MockMethod : IMethod + public class MockMethod : DefaultMethod { - IClass declaringType; - ModifierEnum modifiers; - DomRegion region = DomRegion.Empty; - DomRegion bodyRegion = DomRegion.Empty; - IList attributes = new List(); - string name = String.Empty; - IList parameters = new List(); - IReturnType returnType; - bool isVirtual; - bool isOverride; - - public MockMethod() : this(String.Empty) + public MockMethod() + : this(String.Empty) { } public MockMethod(string name) + : this(null, name) { - this.name = name; - } - - public DomRegion BodyRegion { - get { - return bodyRegion; - } - set { - bodyRegion = value; - } - } - - public IList Parameters { - get { - return parameters; - } - } - - public DomRegion Region { - get { - return region; - } - set { - region = value; - } - } - - public string Name { - get { - return name; - } - set { - name = value; - } - } - - public IReturnType ReturnType { - get { - return returnType; - } - set { - returnType = value; - } - } - - public IClass DeclaringType { - get { - return declaringType; - } - set { - declaringType = value; - } - } - - public ModifierEnum Modifiers { - get { - return modifiers; - } - set { - modifiers = value; - } - } - - public IList Attributes { - get { - return attributes; - } - } - - public IList TypeParameters { - get { - throw new NotImplementedException(); - } - } - - public bool IsConstructor { - get { - throw new NotImplementedException(); - } - } - - public bool IsOperator { - get { - return false; - } - } - - public IList HandlesClauses { - get { - throw new NotImplementedException(); - } - } - - public bool IsExtensionMethod { - get { - throw new NotImplementedException(); - } - } - - public string FullyQualifiedName { - get { - throw new NotImplementedException(); - } - } - - public IReturnType DeclaringTypeReference { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IMember GenericMember { - get { - throw new NotImplementedException(); - } - } - - public string Namespace { - get { - throw new NotImplementedException(); - } - } - - public string DotNetName { - get { - throw new NotImplementedException(); - } - } - - public IList InterfaceImplementations { - get { - throw new NotImplementedException(); - } - } - - public string Documentation { - get { - throw new NotImplementedException(); - } - } - - public bool IsAbstract { - get { - throw new NotImplementedException(); - } - } - - public bool IsSealed { - get { - throw new NotImplementedException(); - } - } - - public bool IsStatic { - get { - throw new NotImplementedException(); - } - } - - public bool IsConst { - get { - throw new NotImplementedException(); - } - } - - public bool IsVirtual { - get { return isVirtual; } - set { isVirtual = value; } - } - - public bool IsPublic { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtected { - get { - throw new NotImplementedException(); - } - } - - public bool IsPrivate { - get { - throw new NotImplementedException(); - } - } - - public bool IsInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsReadonly { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtectedAndInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtectedOrInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsOverride { - get { return isOverride; } - set { isOverride = value; } - } - - public bool IsOverridable { - get { - throw new NotImplementedException(); - } - } - - public bool IsNew { - get { - throw new NotImplementedException(); - } - } - - public bool IsSynthetic { - get { - throw new NotImplementedException(); - } - } - - public object UserData { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public bool IsFrozen { - get { - throw new NotImplementedException(); - } - } - - public IMember CreateSpecializedMember() - { - throw new NotImplementedException(); } - public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree) + public MockMethod(IClass declaringType) + : this(declaringType, String.Empty) { - throw new NotImplementedException(); } - public void Freeze() + public MockMethod(IClass declaringType, string name) + : base(declaringType, name) { - throw new NotImplementedException(); } - public int CompareTo(object obj) + public static MockMethod CreateMockMethodWithoutAnyAttributes() { - throw new NotImplementedException(); + return CreateMockMethodWithAttributes(new MockAttribute[0]); } - public object Clone() + public static MockMethod CreateMockMethodWithAttributes(IList attributes) { - throw new NotImplementedException(); - } - - public ICompilationUnit CompilationUnit { - get { - return declaringType.CompilationUnit; + MockClass mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); + MockMethod mockMethod = new MockMethod(mockClass); + + foreach (MockAttribute attribute in attributes) { + mockMethod.Attributes.Add(attribute); } + + return mockMethod; } - public IProjectContent ProjectContent { - get { - return declaringType.ProjectContent; - } + public static MockMethod CreateMockMethodWithAttribute(MockAttribute attribute) + { + List attributes = new List(); + attributes.Add(attribute); + + return CreateMockMethodWithAttributes(attributes); } - public EntityType EntityType { - get { return EntityType.Method; } + public MockClass MockDeclaringType { + get { return DeclaringType as MockClass; } } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs new file mode 100644 index 0000000000..66c75e5b76 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestFramework.cs @@ -0,0 +1,97 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockNUnitTestFramework : ITestFramework + { + List testRunnersCreated = new List(); + List testDebuggersCreated = new List(); + IUnitTestProcessRunner processRunner; + ITestResultsMonitor testResultsMonitor; + UnitTestingOptions options; + IUnitTestDebuggerService debuggerService; + IUnitTestMessageService messageService; + + public MockNUnitTestFramework(IUnitTestProcessRunner processRunner, + ITestResultsMonitor testResultsMonitor, + UnitTestingOptions options) + : this(null, processRunner, testResultsMonitor, options, null) + { + } + + public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService, + ITestResultsMonitor testResultsMonitor, + UnitTestingOptions options, + IUnitTestMessageService messageService) + : this(debuggerService, null, testResultsMonitor, options, messageService) + { + } + + public MockNUnitTestFramework(IUnitTestDebuggerService debuggerService, + IUnitTestProcessRunner processRunner, + ITestResultsMonitor testResultsMonitor, + UnitTestingOptions options, + IUnitTestMessageService messageService) + { + this.debuggerService = debuggerService; + this.processRunner = processRunner; + this.testResultsMonitor = testResultsMonitor; + this.options = options; + this.messageService = messageService; + } + + public bool IsTestMethod(IMember member) + { + throw new NotImplementedException(); + } + + public bool IsTestClass(IClass c) + { + throw new NotImplementedException(); + } + + public bool IsTestProject(IProject project) + { + throw new NotImplementedException(); + } + + public ITestRunner CreateTestRunner() + { + NUnitTestRunner testRunner = new NUnitTestRunner(processRunner, testResultsMonitor, options); + testRunnersCreated.Add(testRunner); + return testRunner; + } + + public List NUnitTestRunnersCreated { + get { return testRunnersCreated; } + } + + public ITestRunner CreateTestDebugger() + { + NUnitTestDebugger testDebugger = + new NUnitTestDebugger(debuggerService, messageService, testResultsMonitor, options); + testDebuggersCreated.Add(testDebugger); + return testDebugger; + } + + public List NUnitTestDebuggersCreated { + get { return testDebuggersCreated; } + } + + public bool IsBuildNeededBeforeTestRun { + get { return true; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs new file mode 100644 index 0000000000..84707d8827 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockNUnitTestRunnerContext.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockNUnitTestRunnerContext + { + MockProcessRunner processRunner = new MockProcessRunner(); + UnitTestingOptions options = new UnitTestingOptions(new Properties()); + MockTestResultsMonitor testResultsMonitor = new MockTestResultsMonitor(); + + public MockNUnitTestRunnerContext() + { + testResultsMonitor.FileName = @"c:\temp\tmp66.tmp"; + } + + public MockProcessRunner MockProcessRunner { + get { return processRunner; } + } + + public MockTestResultsMonitor MockTestResultsMonitor { + get { return testResultsMonitor; } + } + + public NUnitTestRunner CreateNUnitTestRunner() + { + return new NUnitTestRunner(processRunner, testResultsMonitor, options); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProcessRunner.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProcessRunner.cs new file mode 100644 index 0000000000..17756603f1 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProcessRunner.cs @@ -0,0 +1,81 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Util; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockProcessRunner : IUnitTestProcessRunner + { + bool logStandardOutputAndError = true; + string workingDirectory; + string commandPassedToStartMethod; + string commandArgumentsPassedToStartMethod; + bool killMethodCalled; + + public event EventHandler ProcessExited; + public event LineReceivedEventHandler OutputLineReceived; + public event LineReceivedEventHandler ErrorLineReceived; + + public bool LogStandardOutputAndError { + get { return logStandardOutputAndError; } + set { logStandardOutputAndError = value; } + } + + public string WorkingDirectory { + get { return workingDirectory; } + set { workingDirectory = value; } + } + + public void Start(string command, string arguments) + { + commandPassedToStartMethod = command; + commandArgumentsPassedToStartMethod = arguments; + } + + public string CommandPassedToStartMethod { + get { return commandPassedToStartMethod; } + } + + public string CommandArgumentsPassedToStartMethod { + get { return commandArgumentsPassedToStartMethod; } + } + + public void Kill() + { + killMethodCalled = true; + } + + public bool IsKillMethodCalled { + get { return killMethodCalled; } + set { killMethodCalled = value; } + } + + public void FireProcessExitedEvent() + { + if (ProcessExited != null) { + ProcessExited(this, new EventArgs()); + } + } + + public void FireOutputLineReceivedEvent(LineReceivedEventArgs e) + { + if (OutputLineReceived != null) { + OutputLineReceived(this, e); + } + } + + public void FireErrorLineReceivedEvent(LineReceivedEventArgs e) + { + if (ErrorLineReceived != null) { + ErrorLineReceived(this, e); + } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs index 2b4b301372..72cc37d01c 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockProjectContent.cs @@ -5,16 +5,18 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.Dom; using System; using System.Collections; using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Editor.CodeCompletion; +using ICSharpCode.SharpDevelop.Project; namespace UnitTesting.Tests.Utils { public class MockProjectContent : IProjectContent { - LanguageProperties language; + LanguageProperties language = LanguageProperties.CSharp; List classes = new List(); object project; @@ -31,9 +33,7 @@ namespace UnitTesting.Tests.Utils } public ICollection Classes { - get { - return classes; - } + get { return classes; } } public ICollection NamespaceNames { @@ -49,12 +49,8 @@ namespace UnitTesting.Tests.Utils } public LanguageProperties Language { - get { - return language; - } - set { - language = value; - } + get { return language; } + set { language = value; } } public IUsing DefaultImports { @@ -64,18 +60,16 @@ namespace UnitTesting.Tests.Utils } public object Project { - get { - return project; - } - set { - project = value; - } + get { return project; } + set { project = value; } + } + + public IProject ProjectAsIProject { + get { return project as IProject; } } public SystemTypes SystemTypes { - get { - throw new NotImplementedException(); - } + get { return new SystemTypes(this); } } public string GetXmlDocumentation(string memberTag) @@ -105,7 +99,9 @@ namespace UnitTesting.Tests.Utils public IClass GetClass(string typeName, int typeParameterCount) { - throw new NotImplementedException(); + MockClass c = new MockClass(this); + c.FullyQualifiedName = typeName; + return c; } public bool NamespaceExists(string name) @@ -182,17 +178,15 @@ namespace UnitTesting.Tests.Utils } public string AssemblyName { - get { - throw new NotImplementedException(); - } + get { return String.Empty; } } - public List GetAllContents() + public void AddAllContents(List list, LanguageProperties language, bool lookInReferences) { throw new NotImplementedException(); } - public void AddAllContents(List list, LanguageProperties language, bool lookInReferences) + public List GetAllContents() { throw new NotImplementedException(); } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs new file mode 100644 index 0000000000..3e23933ed1 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRegisteredTestFrameworks.cs @@ -0,0 +1,62 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockRegisteredTestFrameworks : MockTestFramework, IRegisteredTestFrameworks + { + Dictionary testFrameworks = + new Dictionary(); + + public void AddTestFrameworkForProject(IProject project, ITestFramework testFramework) + { + testFrameworks.Add(project, testFramework); + } + + public ITestFramework GetTestFrameworkForProject(IProject project) + { + ITestFramework testFramework = null; + if (testFrameworks.TryGetValue(project, out testFramework)) { + return testFramework; + } + return null; + } + + public ITestRunner CreateTestRunner(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.CreateTestRunner(); + } + return null; + } + + public ITestRunner CreateTestDebugger(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.CreateTestDebugger(); + } + return null; + } + + public bool IsBuildNeededBeforeTestRunForProject(IProject project) + { + ITestFramework testFramework = GetTestFrameworkForProject(project); + if (testFramework != null) { + return testFramework.IsBuildNeededBeforeTestRun; + } + return true; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs new file mode 100644 index 0000000000..ef246e526c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockRunTestCommandContext.cs @@ -0,0 +1,106 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockRunTestCommandContext : IRunTestCommandContext + { + UnitTestingOptions options = new UnitTestingOptions(new Properties()); + MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks(); + MockTestResultsMonitor testResultsMonitor = new MockTestResultsMonitor(); + MockTaskService taskService = new MockTaskService(); + MockUnitTestWorkbench workbench = new MockUnitTestWorkbench(); + MockBuildProjectFactory buildProjectFactory = new MockBuildProjectFactory(); + MockBuildOptions buildOptions = new MockBuildOptions(); + MessageViewCategory unitTestCategory = new MessageViewCategory("Unit Tests"); + MockUnitTestsPad unitTestsPad = new MockUnitTestsPad(); + MockMessageService messageService = new MockMessageService(); + MockSaveAllFilesCommand saveAllFilesCommand = new MockSaveAllFilesCommand(); + + public UnitTestingOptions UnitTestingOptions { + get { return options; } + } + + public IRegisteredTestFrameworks RegisteredTestFrameworks { + get { return testFrameworks; } + } + + public MockRegisteredTestFrameworks MockRegisteredTestFrameworks { + get { return testFrameworks; } + } + + public MockTestResultsMonitor MockTestResultsMonitor { + get { return testResultsMonitor; } + } + + public IUnitTestTaskService TaskService { + get { return taskService; } + } + + public MockTaskService MockTaskService { + get { return taskService; } + } + + public IUnitTestWorkbench Workbench { + get { return workbench; } + } + + public MockUnitTestWorkbench MockUnitTestWorkbench { + get { return workbench; } + } + + public IBuildProjectFactory BuildProjectFactory { + get { return buildProjectFactory; } + } + + public MockBuildProjectFactory MockBuildProjectFactory { + get { return buildProjectFactory; } + } + + public IBuildOptions BuildOptions { + get { return buildOptions; } + } + + public MockBuildOptions MockBuildOptions { + get { return buildOptions; } + } + + public MessageViewCategory UnitTestCategory { + get { return unitTestCategory; } + } + + public IUnitTestsPad OpenUnitTestsPad { + get { return unitTestsPad; } + } + + public MockUnitTestsPad MockUnitTestsPad { + get { return unitTestsPad; } + set { unitTestsPad = value; } + } + + public IUnitTestMessageService MessageService { + get { return messageService; } + } + + public MockMessageService MockMessageService { + get { return messageService; } + } + + public IUnitTestSaveAllFilesCommand SaveAllFilesCommand { + get { return saveAllFilesCommand; } + } + + public MockSaveAllFilesCommand MockSaveAllFilesCommand { + get { return saveAllFilesCommand; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockSaveAllFilesCommand.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockSaveAllFilesCommand.cs new file mode 100644 index 0000000000..f8a2d1cf1e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockSaveAllFilesCommand.cs @@ -0,0 +1,27 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockSaveAllFilesCommand : IUnitTestSaveAllFilesCommand + { + bool saveAllFilesMethodCalled; + + public bool IsSaveAllFilesMethodCalled { + get { return saveAllFilesMethodCalled; } + set { saveAllFilesMethodCalled = value; } + } + + public void SaveAllFiles() + { + saveAllFilesMethodCalled = true; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs new file mode 100644 index 0000000000..08476dce89 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTaskService.cs @@ -0,0 +1,64 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockTaskService : IUnitTestTaskService + { + MessageViewCategory buildMessageViewCategory = new MessageViewCategory("Build"); + bool clearExceptCommentTasksMethodCalled; + bool isInUpdateWhilstClearExceptCommentTasksMethodCalled; + bool inUpdate; + bool somethingWentWrong; + List tasks = new List(); + + public bool IsClearExceptCommentTasksMethodCalled { + get { return clearExceptCommentTasksMethodCalled; } + } + + public void ClearExceptCommentTasks() + { + clearExceptCommentTasksMethodCalled = true; + isInUpdateWhilstClearExceptCommentTasksMethodCalled = inUpdate; + } + + public bool IsInUpdateWhilstClearExceptCommentTasksMethodCalled { + get { return isInUpdateWhilstClearExceptCommentTasksMethodCalled; } + } + + public bool InUpdate { + get { return inUpdate; } + set { inUpdate = value; } + } + + public MessageViewCategory BuildMessageViewCategory { + get { return buildMessageViewCategory; } + } + + public bool SomethingWentWrong { + get { return somethingWentWrong; } + } + + public List Tasks { + get { return tasks; } + } + + public void Add(Task task) + { + if ((task.TaskType == TaskType.Error) || (task.TaskType == TaskType.Warning)) { + somethingWentWrong = true; + } + tasks.Add(task); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs new file mode 100644 index 0000000000..86b81110b2 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFramework.cs @@ -0,0 +1,109 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockTestFramework : ITestFramework + { + IMember isTestMethodMemberParameterUsed; + List testMethods = new List(); + IClass isTestClassParameterUsed; + List testClasses = new List(); + IProject isTestProjectParameterUsed; + List testProjects = new List(); + List testRunnersCreated = new List(); + List testDebuggersCreated = new List(); + bool buildNeededBeforeTestRun = true; + + public MockTestFramework() + { + } + + public bool IsTestMethod(IMember member) + { + isTestMethodMemberParameterUsed = member; + return testMethods.Contains(member); + } + + public IMember IsTestMethodMemberParameterUsed { + get { return isTestMethodMemberParameterUsed; } + } + + public void AddTestMethod(IMember member) + { + testMethods.Add(member); + } + + public bool IsTestClass(IClass c) + { + isTestClassParameterUsed = c; + return testClasses.Contains(c); + } + + public IClass IsTestClassParameterUsed { + get { return isTestClassParameterUsed; } + } + + public void AddTestClass(IClass c) + { + testClasses.Add(c); + } + + public void RemoveTestClass(IClass c) + { + testClasses.Remove(c); + } + + public bool IsTestProject(IProject project) + { + isTestProjectParameterUsed = project; + return testProjects.Contains(project); + } + + public IProject IsTestProjectParameterUsed { + get { return isTestProjectParameterUsed; } + } + + public void AddTestProject(IProject project) + { + testProjects.Add(project); + } + + public ITestRunner CreateTestRunner() + { + MockTestRunner testRunner = new MockTestRunner(); + testRunnersCreated.Add(testRunner); + return testRunner; + } + + public List TestRunnersCreated { + get { return testRunnersCreated; } + } + + public ITestRunner CreateTestDebugger() + { + MockTestRunner testRunner = new MockTestRunner(); + testDebuggersCreated.Add(testRunner); + return testRunner; + } + + public List TestDebuggersCreated { + get { return testDebuggersCreated; } + } + + public bool IsBuildNeededBeforeTestRun { + get { return buildNeededBeforeTestRun; } + set { buildNeededBeforeTestRun = value; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFrameworkFactory.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFrameworkFactory.cs new file mode 100644 index 0000000000..ad0b4a2017 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFrameworkFactory.cs @@ -0,0 +1,43 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockTestFrameworkFactory : ITestFrameworkFactory + { + Dictionary frameworks = new Dictionary(); + List classNames = new List(); + + public MockTestFrameworkFactory() + { + } + + public void Add(string className, ITestFramework framework) + { + frameworks.Add(className, framework); + } + + public ITestFramework Create(string className) + { + classNames.Add(className); + + ITestFramework framework; + if (frameworks.TryGetValue(className, out framework)) { + return framework; + } + return null; + } + + public List ClassNamesPassedToCreateMethod { + get { return classNames; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFrameworksWithNUnitFrameworkSupport.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFrameworksWithNUnitFrameworkSupport.cs new file mode 100644 index 0000000000..8e89aac8e0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestFrameworksWithNUnitFrameworkSupport.cs @@ -0,0 +1,36 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockTestFrameworksWithNUnitFrameworkSupport : NUnitTestFramework, IRegisteredTestFrameworks + { + public ITestFramework GetTestFrameworkForProject(IProject project) + { + throw new NotImplementedException(); + } + + public ITestRunner CreateTestRunner(IProject project) + { + throw new NotImplementedException(); + } + + public ITestRunner CreateTestDebugger(IProject project) + { + throw new NotImplementedException(); + } + + public bool IsBuildNeededBeforeTestRunForProject(IProject project) + { + throw new NotImplementedException(); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs new file mode 100644 index 0000000000..13e3e94890 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestResultsMonitor.cs @@ -0,0 +1,81 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockTestResultsMonitor : ITestResultsMonitor + { + bool startMethodCalled; + bool stopMethodCalled; + bool disposeMethodCalled; + bool readMethodCalled; + string fileName; + + public MockTestResultsMonitor() + { + } + + public event TestFinishedEventHandler TestFinished; + + public bool IsStartMethodCalled { + get { return startMethodCalled; } + } + + public void Start() + { + startMethodCalled = true; + } + + public bool IsStopMethodCalled { + get { return stopMethodCalled; } + set { stopMethodCalled = value; } + } + + public void Stop() + { + stopMethodCalled = true; + } + + public bool IsDisposeMethodCalled { + get { return disposeMethodCalled; } + } + + public void Dispose() + { + disposeMethodCalled = true; + } + + public bool IsReadMethodCalled { + get { return readMethodCalled; } + } + + public void Read() + { + readMethodCalled = true; + } + + public string FileName { + get { return fileName; } + set { fileName = value; } + } + + public void FireTestFinishedEvent(TestResult testResult) + { + OnTestFinished(new TestFinishedEventArgs(testResult)); + } + + protected virtual void OnTestFinished(TestFinishedEventArgs e) + { + if (TestFinished != null) { + TestFinished(this, e); + } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs new file mode 100644 index 0000000000..7e932d0b9c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestRunner.cs @@ -0,0 +1,78 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Util; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockTestRunner : ITestRunner + { + bool disposed = false; + bool stopped = false; + bool started = false; + SelectedTests selectedTests; + + public event TestFinishedEventHandler TestFinished; + public event EventHandler AllTestsFinished; + public event MessageReceivedEventHandler MessageReceived; + + public void Dispose() + { + disposed = true; + } + + public bool IsDisposeCalled { + get { return disposed; } + } + + public void Start(SelectedTests selectedTests) + { + started = true; + this.selectedTests = selectedTests; + } + + public bool IsStartCalled { + get { return started; } + } + + public SelectedTests SelectedTestsPassedToStartMethod { + get { return selectedTests; } + } + + public void Stop() + { + stopped = true; + } + + public bool IsStopCalled { + get { return stopped; } + } + + public void FireTestFinishedEvent(TestResult testResult) + { + if (TestFinished != null) { + TestFinished(this, new TestFinishedEventArgs(testResult)); + } + } + + public void FireAllTestsFinishedEvent() + { + if (AllTestsFinished != null) { + AllTestsFinished(this, new EventArgs()); + } + } + + public void FireMessageReceivedEvent(string message) + { + if (MessageReceived != null) { + MessageReceived(this, new MessageReceivedEventArgs(message)); + } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs index 03a99276d4..f6e1136a05 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockTestTreeView.cs @@ -10,7 +10,7 @@ using ICSharpCode.SharpDevelop.Project; using ICSharpCode.UnitTesting; using System; -namespace UnitTesting.Tests +namespace UnitTesting.Tests.Utils { public class MockTestTreeView : ITestTreeView { @@ -19,44 +19,24 @@ namespace UnitTesting.Tests IProject selectedProject; string selectedNamespace; - public MockTestTreeView() - { - } - public IMember SelectedMethod { - get { - return selectedMethod; - } - set { - selectedMethod = value; - } + get { return selectedMethod; } + set { selectedMethod = value; } } public IClass SelectedClass { - get { - return selectedClass; - } - set { - selectedClass = value; - } + get { return selectedClass; } + set { selectedClass = value; } } public IProject SelectedProject { - get { - return selectedProject; - } - set { - selectedProject = value; - } + get { return selectedProject; } + set { selectedProject = value; } } public string SelectedNamespace { - get { - return selectedNamespace; - } - set { - selectedNamespace = value; - } + get { return selectedNamespace; } + set { selectedNamespace = value; } } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestWorkbench.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestWorkbench.cs new file mode 100644 index 0000000000..c48403987d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestWorkbench.cs @@ -0,0 +1,113 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop; + +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils +{ + public struct ActionArguments { + public Action Action; + public T Arg; + } + + public class MockUnitTestWorkbench : IUnitTestWorkbench + { + List padDescriptors = new List(); + List safeThreadAsyncMethodCalls = new List(); + List safeThreadAsyncMethodCallsWithArguments = + new List(); + bool makeSafeThreadAsyncMethodCallsWithArguments; + bool makeNonGenericSafeThreadAsyncMethodCalls; + List typesPassedToGetPadMethod = new List(); + PadDescriptor compilerMessageViewPadDescriptor; + PadDescriptor errorListPadDescriptor; + + public MockUnitTestWorkbench() + { + compilerMessageViewPadDescriptor = new PadDescriptor(typeof(CompilerMessageView), "Output", String.Empty); + AddPadDescriptor(compilerMessageViewPadDescriptor); + + errorListPadDescriptor = new PadDescriptor(typeof(ErrorListPad), "Errors", String.Empty); + AddPadDescriptor(errorListPadDescriptor); + } + + public PadDescriptor CompilerMessageViewPadDescriptor { + get { return compilerMessageViewPadDescriptor; } + } + + public PadDescriptor ErrorListPadDescriptor { + get { return errorListPadDescriptor; } + } + + public void AddPadDescriptor(PadDescriptor padDescriptor) + { + padDescriptors.Add(padDescriptor); + } + + public PadDescriptor GetPad(Type type) + { + typesPassedToGetPadMethod.Add(type); + + foreach (PadDescriptor padDescriptor in padDescriptors) { + if (padDescriptor.Class == type.FullName) { + return padDescriptor; + } + } + return null; + } + + public List TypesPassedToGetPadMethod { + get { return typesPassedToGetPadMethod; } + } + + public List SafeThreadAsyncMethodCalls { + get { return safeThreadAsyncMethodCalls; } + } + + public bool MakeNonGenericSafeThreadAsyncMethodCalls { + get { return makeNonGenericSafeThreadAsyncMethodCalls; } + set { makeNonGenericSafeThreadAsyncMethodCalls = value; } + } + + public void SafeThreadAsyncCall(Action method) + { + safeThreadAsyncMethodCalls.Add(method); + + if (makeNonGenericSafeThreadAsyncMethodCalls) { + method(); + } + } + + public bool MakeSafeThreadAsyncMethodCallsWithArguments { + get { return makeSafeThreadAsyncMethodCallsWithArguments; } + set { makeSafeThreadAsyncMethodCallsWithArguments = value; } + } + + public void SafeThreadAsyncCall(Action method, T arg) + { + ActionArguments actionArgs = new ActionArguments(); + actionArgs.Action = method; + actionArgs.Arg = arg; + + safeThreadAsyncMethodCallsWithArguments.Add(actionArgs); + + if (makeSafeThreadAsyncMethodCallsWithArguments) { + method(arg); + } + } + + public List SafeThreadAsyncMethodCallsWithArguments { + get { return safeThreadAsyncMethodCallsWithArguments; } + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs new file mode 100644 index 0000000000..5e25054058 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/MockUnitTestsPad.cs @@ -0,0 +1,76 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public class MockUnitTestsPad : IUnitTestsPad + { + bool updateToolbarMethodCalled; + bool bringToFrontMethodCalled; + bool resetTestResultsMethodCalled; + List projects = new List(); + List testProjects = new List(); + + public bool IsUpdateToolbarMethodCalled { + get { return updateToolbarMethodCalled; } + set { updateToolbarMethodCalled = value; } + } + + public void UpdateToolbar() + { + updateToolbarMethodCalled = true; + } + + public bool IsBringToFrontMethodCalled { + get { return bringToFrontMethodCalled; } + } + + public void BringToFront() + { + bringToFrontMethodCalled = true; + } + + public bool IsResetTestResultsMethodCalled { + get { return resetTestResultsMethodCalled; } + } + + public void ResetTestResults() + { + resetTestResultsMethodCalled = true; + } + + public void AddProject(IProject project) + { + projects.Add(project); + } + + public IProject[] GetProjects() + { + return projects.ToArray(); + } + + public TestProject GetTestProject(IProject project) + { + foreach (TestProject testProject in testProjects) { + if (testProject.Project == project) { + return testProject; + } + } + return null; + } + + public void AddTestProject(TestProject testProject) + { + testProjects.Add(testProject); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/ResourceManager.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/ResourceManager.cs index 613979906a..721c62b633 100644 --- a/src/AddIns/Analysis/UnitTesting/Test/Utils/ResourceManager.cs +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/ResourceManager.cs @@ -30,6 +30,7 @@ namespace UnitTesting.Tests.Utils initialized = true; Assembly exe = Assembly.Load("SharpDevelop"); ResourceService.RegisterNeutralImages(new System.Resources.ResourceManager("Resources.BitmapResources", exe)); + ResourceService.RegisterNeutralStrings(new System.Resources.ResourceManager("Resources.StringResources", exe)); } } } diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/SelectedTestsHelper.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/SelectedTestsHelper.cs new file mode 100644 index 0000000000..864e9b9821 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/SelectedTestsHelper.cs @@ -0,0 +1,33 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public static class SelectedTestsHelper + { + public static SelectedTests CreateSelectedTestMethod() + { + MockCSharpProject project = new MockCSharpProject(); + + MockMethod methodToTest = MockMethod.CreateMockMethodWithoutAnyAttributes(); + methodToTest.FullyQualifiedName = "MyTests.MyTestClass.MyTestMethod"; + + MockClass classToTest = methodToTest.DeclaringType as MockClass; + classToTest.SetDotNetName("MyTests.MyTestClass"); + + MockTestTreeView treeView = new MockTestTreeView(); + treeView.SelectedProject = project; + treeView.SelectedMethod = methodToTest; + + return new SelectedTests(treeView, null); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs new file mode 100644 index 0000000000..de237c0dc5 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/TaskComparison.cs @@ -0,0 +1,114 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text; +using ICSharpCode.SharpDevelop; + +namespace UnitTesting.Tests.Utils +{ + public class TaskComparison + { + bool match; + Task lhs; + Task rhs; + string shortMismatchReason = String.Empty; + StringBuilder mismatchReason = new StringBuilder(); + + public TaskComparison(Task lhs, Task rhs) + { + this.lhs = lhs; + this.rhs = rhs; + Compare(); + } + + void Compare() + { + match = false; + + if ((lhs == null) && (rhs == null)) { + match = true; + return; + } + + if ((lhs == null) || (rhs == null)) { + AddNullTaskMismatchReason(); + } else if (lhs.TaskType != rhs.TaskType) { + AddTaskTypeMismatchReason(); + } else if (lhs.FileName != rhs.FileName) { + AddFileNameMismatchReason(); + } else if (lhs.Description != rhs.Description) { + AddDescriptionMismatchReason(); + } else if (lhs.Column != rhs.Column) { + AddColumnMismatchReason(); + } else if (lhs.Line != rhs.Line) { + AddLineMismatchReason(); + } else { + match = true; + } + } + + public bool IsMatch { + get { return match; } + } + + public string MismatchReason { + get { return mismatchReason.ToString(); } + } + + void AddNullTaskMismatchReason() + { + shortMismatchReason = "One task is null."; + AddMismatchedExpectedAndActualValues(lhs, rhs); + } + + void AddTaskTypeMismatchReason() + { + shortMismatchReason = "TaskTypes are different."; + AddMismatchedExpectedAndActualValues(lhs.TaskType, rhs.TaskType); + } + + void AddMismatchedExpectedAndActualValues(object expected, object actual) + { + mismatchReason.AppendLine(shortMismatchReason); + mismatchReason.AppendLine("Expected: " + ObjectToString(expected)); + mismatchReason.AppendLine("But was: " + ObjectToString(actual)); + } + + static string ObjectToString(object obj) + { + if (obj != null) { + return obj.ToString(); + } + return "(null)"; + } + + void AddFileNameMismatchReason() + { + shortMismatchReason = "FileNames are different."; + AddMismatchedExpectedAndActualValues(lhs.FileName, rhs.FileName); + } + + void AddDescriptionMismatchReason() + { + shortMismatchReason = "Descriptions are different."; + AddMismatchedExpectedAndActualValues(lhs.Description, rhs.Description); + } + + void AddColumnMismatchReason() + { + shortMismatchReason = "Columns are different."; + AddMismatchedExpectedAndActualValues(lhs.Column, rhs.Column); + } + + void AddLineMismatchReason() + { + shortMismatchReason = "Lines are different."; + AddMismatchedExpectedAndActualValues(lhs.Line, rhs.Line); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs new file mode 100644 index 0000000000..a86a1465e2 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/TestProjectHelper.cs @@ -0,0 +1,62 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace UnitTesting.Tests.Utils +{ + public static class TestProjectHelper + { + public static TestProject CreateTestProjectWithTestClassAndSingleTestMethod(IProject project, + string className, + string methodName) + { + string[] methodNames = new string[] { methodName }; + return CreateTestProjectWithTestClassTestMethods(project, className, methodNames); + } + + public static TestProject CreateTestProjectWithTestClassAndSingleTestMethod(string className, string methodName) + { + MockCSharpProject project = new MockCSharpProject(); + return CreateTestProjectWithTestClassAndSingleTestMethod(project, className, methodName); + } + + public static TestProject CreateTestProjectWithTestClassTestMethods(string className, string[] methodNames) + { + MockCSharpProject project = new MockCSharpProject(); + return CreateTestProjectWithTestClassTestMethods(project, className, methodNames); + } + + public static TestProject CreateTestProjectWithTestClassTestMethods(IProject project, string className, string[] methodNames) + { + MockRegisteredTestFrameworks testFrameworks = new MockRegisteredTestFrameworks(); + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.MockProjectContent.Project = project; + c.SetDotNetName(className); + c.CompilationUnit.FileName = @"c:\projects\tests\MyTests.cs"; + TestClass testClass = new TestClass(c, testFrameworks); + + foreach (string methodName in methodNames) { + MockMethod method = new MockMethod(c, methodName); + method.Region = new DomRegion(4, 20); + c.Methods.Add(method); + + TestMethod testMethod = new TestMethod(method); + testClass.TestMethods.Add(testMethod); + } + + c.Project.Name = "TestProject"; + TestProject testProject = new TestProject(c.Project, c.ProjectContent, testFrameworks); + testProject.TestClasses.Add(testClass); + + return testProject; + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs new file mode 100644 index 0000000000..e4d25c993a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithAttributesTestFixture.cs @@ -0,0 +1,95 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateMockClassWithAttributesTestFixture + { + MockClass mockClass; + MockAttribute firstAttribute; + MockAttribute secondAttribute; + + [SetUp] + public void Init() + { + firstAttribute = new MockAttribute("first"); + secondAttribute = new MockAttribute("second"); + List attributes = new List(); + attributes.Add(firstAttribute); + attributes.Add(secondAttribute); + + mockClass = MockClass.CreateMockClassWithAttributes(attributes); + } + + [Test] + public void ProjectContentLanguageIsCSharp() + { + Assert.AreEqual(LanguageProperties.CSharp, mockClass.ProjectContent.Language); + } + + [Test] + public void ProjectContentProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockClass.ProjectContent.Project as MockCSharpProject); + } + + [Test] + public void ClassHasTwoAttributes() + { + Assert.AreEqual(2, mockClass.Attributes.Count); + } + + [Test] + public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() + { + Assert.AreEqual("first", mockClass.Attributes[0].AttributeType.FullyQualifiedName); + } + + [Test] + public void SecondClassAttributeHasAttributeTypeWithFullyQualifiedNameOfSeocnd() + { + Assert.AreEqual("second", mockClass.Attributes[1].AttributeType.FullyQualifiedName); + } + + [Test] + public void ProjectContentContainsMockClass() + { + Assert.IsTrue(mockClass.ProjectContent.Classes.Contains(mockClass)); + } + + [Test] + public void CompoundClassIsSameAsMockClass() + { + Assert.AreEqual(mockClass, mockClass.GetCompoundClass()); + } + + [Test] + public void MockClassHasDefaultReturnType() + { + Assert.AreEqual(mockClass, mockClass.DefaultReturnType.GetUnderlyingClass()); + } + + [Test] + public void ClassHasCompilationUnit() + { + Assert.IsNotNull(mockClass.CompilationUnit); + } + + [Test] + public void ClassCompilationUnitHasSameProjectContentAsClass() + { + Assert.AreEqual(mockClass.ProjectContent, mockClass.CompilationUnit.ProjectContent); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs new file mode 100644 index 0000000000..3e0c878035 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithSingleAttributeTestFixture.cs @@ -0,0 +1,53 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateMockClassWithSingleAttributeTestFixture + { + MockClass mockClass; + MockAttribute firstAttribute; + + [SetUp] + public void Init() + { + firstAttribute = new MockAttribute("first"); + mockClass = MockClass.CreateMockClassWithAttribute(firstAttribute); + } + + [Test] + public void ProjectContentLanguageIsCSharp() + { + Assert.AreEqual(LanguageProperties.CSharp, mockClass.ProjectContent.Language); + } + + [Test] + public void ProjectContentProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockClass.ProjectContent.Project as MockCSharpProject); + } + + [Test] + public void ClassHasOneAttribute() + { + Assert.AreEqual(1, mockClass.Attributes.Count); + } + + [Test] + public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() + { + Assert.AreEqual("first", mockClass.Attributes[0].AttributeType.FullyQualifiedName); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs new file mode 100644 index 0000000000..8b474ff5c3 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockClassWithoutAnyAttributesTestFixture.cs @@ -0,0 +1,56 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateMockClassWithoutAnyAttributesTestFixture + { + MockClass mockClass; + + [SetUp] + public void Init() + { + mockClass = MockClass.CreateMockClassWithoutAnyAttributes(); + } + + [Test] + public void ProjectContentLanguageIsCSharp() + { + Assert.AreEqual(LanguageProperties.CSharp, mockClass.ProjectContent.Language); + } + + [Test] + public void ProjectContentProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockClass.ProjectContent.Project as MockCSharpProject); + } + + [Test] + public void ClassHasNoAttributes() + { + Assert.AreEqual(0, mockClass.Attributes.Count); + } + + [Test] + public void ProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockClass.Project); + } + + [Test] + public void ProjectContentContainsMockClass() + { + Assert.IsTrue(mockClass.ProjectContent.Classes.Contains(mockClass)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs new file mode 100644 index 0000000000..722190e08d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithAttributesTestFixture.cs @@ -0,0 +1,71 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateMockMethodWithAttributesTestFixture + { + MockMethod mockMethod; + MockAttribute firstAttribute; + MockAttribute secondAttribute; + + [SetUp] + public void Init() + { + firstAttribute = new MockAttribute("first"); + secondAttribute = new MockAttribute("second"); + List attributes = new List(); + attributes.Add(firstAttribute); + attributes.Add(secondAttribute); + + mockMethod = MockMethod.CreateMockMethodWithAttributes(attributes); + } + + [Test] + public void DeclaringTypeProjectContentLanguageIsCSharp() + { + Assert.AreEqual(LanguageProperties.CSharp, mockMethod.DeclaringType.ProjectContent.Language); + } + + [Test] + public void ProjectContentProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockMethod.DeclaringType.ProjectContent.Project as MockCSharpProject); + } + + [Test] + public void MethodHasTwoAttributes() + { + Assert.AreEqual(2, mockMethod.Attributes.Count); + } + + [Test] + public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() + { + Assert.AreEqual("first", mockMethod.Attributes[0].AttributeType.FullyQualifiedName); + } + + [Test] + public void SecondClassAttributeHasAttributeTypeWithFullyQualifiedNameOfSeocnd() + { + Assert.AreEqual("second", mockMethod.Attributes[1].AttributeType.FullyQualifiedName); + } + + [Test] + public void MethodDeclaringTypeHasCompilationUnit() + { + Assert.IsNotNull(mockMethod.DeclaringType.CompilationUnit); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs new file mode 100644 index 0000000000..75482c19c6 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithSingleAttributeTestFixture.cs @@ -0,0 +1,53 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateMockMethodWithSingleAttributeTestFixture + { + MockMethod mockMethod; + MockAttribute firstAttribute; + + [SetUp] + public void Init() + { + firstAttribute = new MockAttribute("first"); + mockMethod = MockMethod.CreateMockMethodWithAttribute(firstAttribute); + } + + [Test] + public void DeclaringTypeProjectContentLanguageIsCSharp() + { + Assert.AreEqual(LanguageProperties.CSharp, mockMethod.DeclaringType.ProjectContent.Language); + } + + [Test] + public void ProjectContentProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockMethod.DeclaringType.ProjectContent.Project as MockCSharpProject); + } + + [Test] + public void MethodHasOneAttribute() + { + Assert.AreEqual(1, mockMethod.Attributes.Count); + } + + [Test] + public void FirstClassAttributeHasAttributeTypeWithFullyQualifiedNameOfFirst() + { + Assert.AreEqual("first", mockMethod.Attributes[0].AttributeType.FullyQualifiedName); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs new file mode 100644 index 0000000000..434d3ff657 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateMockMethodWithoutAnyAttributesTestFixture.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateMockMethodWithoutAnyAttributesTestFixture + { + MockMethod mockMethod; + + [SetUp] + public void Init() + { + mockMethod = MockMethod.CreateMockMethodWithoutAnyAttributes(); + } + + [Test] + public void DeclaringTypeProjectContentLanguageIsCSharp() + { + Assert.AreEqual(LanguageProperties.CSharp, mockMethod.DeclaringType.ProjectContent.Language); + } + + [Test] + public void ProjectContentProjectIsMockCSharpProject() + { + Assert.IsNotNull(mockMethod.DeclaringType.ProjectContent.Project as MockCSharpProject); + } + + [Test] + public void MethodHasNoAttributes() + { + Assert.AreEqual(0, mockMethod.Attributes.Count); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs new file mode 100644 index 0000000000..4261edeae9 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateProjectWithOutputPathTestFixture.cs @@ -0,0 +1,71 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateProjectWithOutputPathTestFixture + { + MockCSharpProject project; + + [SetUp] + public void Init() + { + project = new MockCSharpProject(); + } + + [Test] + public void ProjectOutputTypeIsLibrary() + { + Assert.AreEqual(OutputType.Library, project.OutputType); + } + + [Test] + public void ProjectFileNameIsProjectsMyTestsMyTestsCsproj() + { + string expectedFileName = @"c:\projects\MyTests\MyTests.csproj"; + Assert.AreEqual(expectedFileName, project.FileName); + } + + [Test] + public void ProjectAssemblyNameIsMyTests() + { + Assert.AreEqual("MyTests", project.AssemblyName); + } + + [Test] + public void ProjectOutputPathIsBinDebug() + { + Assert.AreEqual(@"bin\Debug\", project.GetProperty(null, null, "OutputPath")); + } + + [Test] + public void OutputAssemblyFullPathIsProjectsMyTestsMyTestsBinDebugMyTestsDll() + { + string expectedFileName = @"c:\projects\MyTests\bin\Debug\MyTests.dll"; + Assert.AreEqual(expectedFileName, project.OutputAssemblyFullPath); + } + + [Test] + public void TargetFrameworkVersionIsVersion40() + { + Assert.AreEqual("v4.0", project.TargetFrameworkVersion); + } + + [Test] + public void PlatformTargetIs32Bit() + { + Assert.AreEqual("x86", project.GetEvaluatedProperty("PlatformTarget")); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs new file mode 100644 index 0000000000..a0a757602c --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithOneTestMethodTestFixture.cs @@ -0,0 +1,113 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateTestProjectWithOneTestMethodTestFixture + { + TestProject testProject; + TestClass testClass; + TestMethod testMethod; + + [SetUp] + public void Init() + { + testProject = + TestProjectHelper.CreateTestProjectWithTestClassAndSingleTestMethod("MyNamespace.MyClass", "MyTestMethod"); + + if (testProject.TestClasses.Count > 0) { + testClass = testProject.TestClasses[0]; + if (testClass.TestMethods.Count > 0) { + testMethod = testClass.TestMethods[0]; + } + } + } + + [Test] + public void TestProjectNameIsTestProject() + { + string expectedName = "TestProject"; + Assert.AreEqual(expectedName, testProject.Name); + } + + [Test] + public void TestProjectNameMatchesProjectName() + { + Assert.AreEqual(testProject.Project.Name, testProject.Name); + } + + [Test] + public void TestProjectHasOneTestClass() + { + Assert.AreEqual(1, testProject.TestClasses.Count); + } + + [Test] + public void TestClassDotNetNameIsMyNamespaceMyClass() + { + string expectedName = "MyNamespace.MyClass"; + Assert.AreEqual(expectedName, testClass.Class.DotNetName); + } + + [Test] + public void TestClassCompilationUnitFileNameIsProjectsTestsMyTestsCs() + { + string fileName = @"c:\projects\tests\MyTests.cs"; + Assert.AreEqual(fileName, testClass.Class.CompilationUnit.FileName); + } + + [Test] + public void TestClassHasOneTestMethod() + { + Assert.AreEqual(1, testClass.TestMethods.Count); + } + + [Test] + public void TestMethodNameIsMyTestMethod() + { + Assert.AreEqual("MyTestMethod", testMethod.Name); + } + + [Test] + public void TestMethodDeclaringTypeIsNotNull() + { + Assert.IsNotNull(testMethod.Method.DeclaringType); + } + + [Test] + public void TestMethodDeclaringTypeEqualsTestClass() + { + Assert.AreEqual(testClass.Class, testMethod.Method.DeclaringType); + } + + [Test] + public void TestMethodRegionIsLine4Column20() + { + DomRegion expectedRegion = new DomRegion(4, 20); + Assert.AreEqual(expectedRegion, testMethod.Method.Region); + } + + [Test] + public void ClassHasOneMethod() + { + Assert.AreEqual(1, testClass.Class.Methods.Count); + } + + [Test] + public void ClassMethodMatchesTestMethodMethod() + { + Assert.AreEqual(testClass.Class.Methods[0], testMethod.Method); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs new file mode 100644 index 0000000000..c320052b01 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/CreateTestProjectWithTwoTestMethodsTestFixture.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class CreateTestProjectWithTwoTestMethodsTestFixture + { + TestProject testProject; + TestClass testClass; + + [SetUp] + public void Init() + { + string[] methods = new string[] { "Foo", "Bar" }; + testProject = + TestProjectHelper.CreateTestProjectWithTestClassTestMethods("MyClass", methods); + + testClass = testProject.TestClasses[0]; + } + + [Test] + public void TestProjectWithTwoTestMethodsHasTwoMethods() + { + Assert.AreEqual(2, testClass.TestMethods.Count); + } + + [Test] + public void FirstTestMethodNameIsFoo() + { + Assert.AreEqual("Foo", testClass.TestMethods[0].Name); + } + + [Test] + public void SecondTestMethodNameIsBar() + { + Assert.AreEqual("Bar", testClass.TestMethods[1].Name); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs new file mode 100644 index 0000000000..8c37ad3864 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/DerivedRunTestCommandTestFixture.cs @@ -0,0 +1,100 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class DerivedRunTestCommandTestFixture + { + DerivedRunTestCommand runTestCommand; + + [SetUp] + public void Init() + { + MockRunTestCommandContext context = new MockRunTestCommandContext(); + runTestCommand = new DerivedRunTestCommand(context); + } + + [TearDown] + public void TearDown() + { + AbstractRunTestCommand.RunningTestCommand = null; + } + + [Test] + public void IsOnBeforeRunTestsMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(runTestCommand.IsOnBeforeRunTestsMethodCalled); + } + + [Test] + public void IsOnBeforeRunTestsMethodCalledReturnsTrueAfterOnBeforeRunMethodCalled() + { + runTestCommand.CallOnBeforeRunTestsMethod(); + Assert.IsTrue(runTestCommand.IsOnBeforeRunTestsMethodCalled); + } + + [Test] + public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsFalseByDefault() + { + AbstractRunTestCommand.RunningTestCommand = null; + runTestCommand.CallOnBeforeRunTestsMethod(); + Assert.IsFalse(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); + } + + [Test] + public void IsRunningTestPropertyWhenOnBeforeRunCalledReturnsTrueWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled() + { + AbstractRunTestCommand.RunningTestCommand = runTestCommand; + runTestCommand.CallOnBeforeRunTestsMethod(); + Assert.IsTrue(runTestCommand.IsRunningTestPropertyWhenOnBeforeRunCalled); + } + + [Test] + public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNullByDefault() + { + AbstractRunTestCommand.RunningTestCommand = null; + runTestCommand.CallOnBeforeRunTestsMethod(); + Assert.IsNull(runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); + } + + [Test] + public void RunningTestCommandPropertyWhenOnBeforeRunCalledReturnsNonNullWhenRunningTestCommandIsNonNullWhenOnBeforeRunMethodCalled() + { + AbstractRunTestCommand.RunningTestCommand = runTestCommand; + runTestCommand.CallOnBeforeRunTestsMethod(); + Assert.AreEqual(runTestCommand, runTestCommand.RunningTestCommandPropertyWhenOnBeforeRunCalled); + } + + [Test] + public void IsOnAfterRunTestsMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(runTestCommand.IsOnAfterRunTestsMethodCalled); + } + + [Test] + public void IsOnAfterRunTestsMethodCalledReturnsTrueAfterOnBeforeRunMethodCalled() + { + runTestCommand.CallOnAfterRunTestsMethod(); + Assert.IsTrue(runTestCommand.IsOnAfterRunTestsMethodCalled); + } + + [Test] + public void TestRunnersCreatedAreSaved() + { + MockTestRunner testRunner = runTestCommand.CallCreateTestRunner(null) as MockTestRunner; + MockTestRunner[] expectedTestRunners = new MockTestRunner[] { testRunner }; + Assert.AreEqual(expectedTestRunners, runTestCommand.TestRunnersCreated.ToArray()); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockAddInTreeTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockAddInTreeTestFixture.cs new file mode 100644 index 0000000000..f21737f422 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockAddInTreeTestFixture.cs @@ -0,0 +1,45 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.Core; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockAddInTreeTestFixture + { + MockAddInTree addinTree; + List myItems; + + [SetUp] + public void Init() + { + myItems = new List(); + myItems.Add("a"); + myItems.Add("b"); + + addinTree = new MockAddInTree(); + addinTree.AddItems("MyItems", myItems); + } + + [Test] + public void BuildItemsReturnsMyItemsListWhenMyItemsPathNameUsedAsParameter() + { + Assert.AreEqual(myItems, addinTree.BuildItems("MyItems", null)); + } + + [Test] + public void BuildItemsThrowsExceptionWhenUnknownPathNamedUsedAsParameter() + { + Assert.Throws(delegate { addinTree.BuildItems("Unknown", null); }); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockBuildOptionsTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockBuildOptionsTestFixture.cs new file mode 100644 index 0000000000..30353ec103 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockBuildOptionsTestFixture.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockBuildOptionsTestFixture + { + MockBuildOptions buildOptions; + + [SetUp] + public void Init() + { + buildOptions = new MockBuildOptions(); + } + + [Test] + public void ShowErrorListAfterBuildReturnsTrueByDefault() + { + Assert.IsTrue(buildOptions.ShowErrorListAfterBuild); + } + + [Test] + public void ShowErrorListAfterBuildReturnsFalseWhenSetToFalse() + { + buildOptions.ShowErrorListAfterBuild = false; + Assert.IsFalse(buildOptions.ShowErrorListAfterBuild); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockBuildProjectBeforeTestRunTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockBuildProjectBeforeTestRunTestFixture.cs new file mode 100644 index 0000000000..dd801fc4db --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockBuildProjectBeforeTestRunTestFixture.cs @@ -0,0 +1,88 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockBuildProjectBeforeTestRunTestFixture + { + MockBuildProjectBeforeTestRun buildProject; + MockBuildProjectBeforeTestRun createdBuildProject; + MockCSharpProject project; + MockBuildProjectFactory factory; + + [SetUp] + public void Init() + { + factory = new MockBuildProjectFactory(); + project = new MockCSharpProject(); + buildProject = new MockBuildProjectBeforeTestRun(); + factory.AddBuildProjectBeforeTestRun(buildProject); + + createdBuildProject = factory.CreateBuildProjectBeforeTestRun(project) as MockBuildProjectBeforeTestRun; + } + + [Test] + public void CreateBuildProjectBeforeTestRunReturnsObjectPassedToAddBuildProjectBeforeTestRunMethod() + { + Assert.AreEqual(buildProject, createdBuildProject); + } + + [Test] + public void ProjectPassedToBuildProjectObject() + { + Assert.AreEqual(project, buildProject.Project); + } + + [Test] + public void CallingCreateBuildProjectBeforeTestRunAgainReturnsNull() + { + Assert.IsNull(factory.CreateBuildProjectBeforeTestRun(null)); + } + + [Test] + public void FireBuildCompleteEventFiresBuildCompleteEvent() + { + bool eventFired = false; + buildProject.BuildComplete += delegate { eventFired = true; }; + buildProject.FireBuildCompleteEvent(); + + Assert.IsTrue(eventFired); + } + + [Test] + public void IsRunMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(buildProject.IsRunMethodCalled); + } + + [Test] + public void IsRunMethodCalledReturnsTrueAfterRunMethodCalled() + { + buildProject.Run(); + Assert.IsTrue(buildProject.IsRunMethodCalled); + } + + [Test] + public void LastBuildResultsIsNull() + { + Assert.IsNull(buildProject.LastBuildResults); + } + + [Test] + public void LastBuildResultsIsNotNullAfterRun() + { + buildProject.Run(); + Assert.IsNotNull(buildProject.LastBuildResults); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTestFixture.cs new file mode 100644 index 0000000000..493beb571a --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockClassTestFixture.cs @@ -0,0 +1,167 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockClassTestFixture + { + MockClass outerClass; + MockClass innerClass; + + [Test] + public void ClassCreatedWithExpectedFullyQualifiedName() + { + string fullyQualifiedName = "MyNamespace.MyClass"; + MockClass c = new MockClass(fullyQualifiedName); + Assert.AreEqual(fullyQualifiedName, c.FullyQualifiedName); + } + + [Test] + public void ClassCreatedWithFullyQualifiedNameHasMatchingDotNetName() + { + string fullyQualifiedName = "MyNamespace.MyClass"; + MockClass c = new MockClass(fullyQualifiedName); + Assert.AreEqual(fullyQualifiedName, c.DotNetName); + } + + [Test] + public void ClassCreatedWithExpectedDotNetName() + { + string fullyQualifiedName = "MyNamespace.MyClass.InnerClass"; + string dotNetName = "MyNamespace.MyClass+InnerClass"; + MockClass c = new MockClass(fullyQualifiedName, dotNetName); + Assert.AreEqual(dotNetName, c.DotNetName); + } + + [Test] + public void ClassCreatedWithNamespaceTakenFromFullyQualifiedName() + { + string fullyQualifiedName = "MyNamespace.MySubNamespace.MyClass"; + MockClass c = new MockClass(fullyQualifiedName); + string expectedNamespace = "MyNamespace.MySubNamespace"; + Assert.AreEqual(expectedNamespace, c.Namespace); + } + + [Test] + public void ClassCreatedWithNameTakenFromFullyQualifiedName() + { + string fullyQualifiedName = "MyNamespace.MySubNamespace.MyClass"; + MockClass c = new MockClass(fullyQualifiedName); + string expectedName = "MyClass"; + Assert.AreEqual(expectedName, c.Name); + } + + [Test] + public void ClassCreatedWithNoNamespaceInFullyQualifiedNameHasNamespaceOfEmptyString() + { + string fullyQualifiedName = "MyClass"; + MockClass c = new MockClass(fullyQualifiedName); + string expectedNamespace = String.Empty; + Assert.AreEqual(expectedNamespace, c.Namespace); + } + + [Test] + public void ClassHasCompilationUnit() + { + MockClass c = new MockClass(); + Assert.IsNotNull(c.CompilationUnit); + } + + [Test] + public void ClassHasMockProjectContent() + { + MockClass c = new MockClass(); + Assert.IsNotNull(c.ProjectContent as MockProjectContent); + } + + [Test] + public void CompoundClassIsClassItself() + { + MockClass c = new MockClass(); + Assert.AreEqual(c, c.GetCompoundClass()); + } + + [Test] + public void ClassDefaultReturnTypeGetUnderlyingClassMatchesOriginalMockClass() + { + MockClass c = new MockClass(); + IReturnType returnType = c.DefaultReturnType; + Assert.AreEqual(c, returnType.GetUnderlyingClass()); + } + + [Test] + public void ClassWithInnerClassHasDeclaringTypeAsOuterClass() + { + CreateClassWithInnerClass(); + Assert.AreEqual(outerClass, innerClass.DeclaringType); + } + + void CreateClassWithInnerClass() + { + outerClass = new MockClass("MyTests.A"); + innerClass = new MockClass("MyTests.A.InnerATest", "MyTests.A+InnerATest", outerClass); + } + + [Test] + public void InnerClassGetCompoundClassReturnsInnerClass() + { + CreateClassWithInnerClass(); + Assert.AreEqual(innerClass, innerClass.GetCompoundClass()); + } + + [Test] + public void InnerClassAddedToOuterClassInnerClassCollection() + { + CreateClassWithInnerClass(); + Assert.AreEqual(innerClass, outerClass.InnerClasses[0]); + } + + [Test] + public void ClassAddedToBaseTypesBecomesBaseClass() + { + MockClass c = new MockClass(); + MockClass baseClass = new MockClass(); + DefaultReturnType returnType = new DefaultReturnType(baseClass); + c.BaseTypes.Add(returnType); + Assert.AreEqual(baseClass, c.BaseClass); + } + + [Test] + public void BaseClassPropertyReturnsClassAddedUsingAddBaseClassMethod() + { + MockClass c = new MockClass(); + MockClass baseClass = new MockClass(); + c.AddBaseClass(baseClass); + Assert.AreEqual(baseClass, c.BaseClass); + } + + [Test] + public void ClassWithProjectContentHasExpectedDotNetName() + { + MockProjectContent projectContent = new MockProjectContent(); + string expectedName = "MyNamespace.MyTests"; + MockClass c = new MockClass(projectContent, expectedName); + Assert.AreEqual(expectedName, c.DotNetName); + } + + [Test] + public void GetCompoundClassReturnsClassSetWithSetCompoundClass() + { + MockClass c = new MockClass(); + MockClass compoundClass = new MockClass(); + c.SetCompoundClass(compoundClass); + Assert.AreEqual(compoundClass, c.GetCompoundClass()); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockDebuggerServiceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockDebuggerServiceTestFixture.cs new file mode 100644 index 0000000000..750dab7b01 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockDebuggerServiceTestFixture.cs @@ -0,0 +1,113 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockDebuggerServiceTestFixture + { + MockDebuggerService debuggerService; + MockDebugger debugger; + + [SetUp] + public void Init() + { + debuggerService = new MockDebuggerService(); + debugger = debuggerService.CurrentDebugger as MockDebugger; + } + + [Test] + public void IsDebuggerLoadedReturnsFalseByDefault() + { + Assert.IsFalse(debuggerService.IsDebuggerLoaded); + } + + [Test] + public void IsDebuggerLoadedReturnsTrueAfterBeingSetToTrue() + { + debuggerService.IsDebuggerLoaded = true; + Assert.IsTrue(debuggerService.IsDebuggerLoaded); + } + + [Test] + public void DebuggerIsDebuggingReturnsFalseByDefault() + { + Assert.IsFalse(debugger.IsDebugging); + } + + [Test] + public void MockDebuggerIsSameAsCurrentDebugger() + { + Assert.AreEqual(debuggerService.CurrentDebugger, debuggerService.MockDebugger); + } + + [Test] + public void DebuggerIsDebuggingReturnsTrueAfterBeingSetToTrue() + { + debugger.IsDebugging = true; + Assert.IsTrue(debugger.IsDebugging); + } + + [Test] + public void DebuggerIsStopCalledReturnsFalseByDefault() + { + Assert.IsFalse(debugger.IsStopCalled); + } + + [Test] + public void DebuggerIsStopCalledReturnsTrueAfterStopMethodCalled() + { + debugger.Stop(); + Assert.IsTrue(debugger.IsStopCalled); + } + + [Test] + public void DebuggerFireDebugStoppedEventFiresDebugStoppedEvent() + { + bool fired = false; + debugger.DebugStopped += delegate { + fired = true; + }; + debugger.FireDebugStoppedEvent(); + + Assert.IsTrue(fired); + } + + [Test] + public void DebuggerProcessStartInfoReturnsNullByDefault() + { + Assert.IsNull(debugger.ProcessStartInfo); + } + + [Test] + public void DebuggerProcessStartInfoSavedAfterStartMethodCalled() + { + ProcessStartInfo startInfo = new ProcessStartInfo(); + debugger.Start(startInfo); + + Assert.AreEqual(startInfo, debugger.ProcessStartInfo); + } + + [Test] + public void DebuggerWillThrowExceptionIfConfiguredWhenStartMethodCalled() + { + ApplicationException expectedException = new ApplicationException(); + debugger.ThrowExceptionOnStart = expectedException; + + ProcessStartInfo processStartInfo = new ProcessStartInfo(); + ApplicationException actualException = + Assert.Throws(delegate { debugger.Start(processStartInfo); }); + Assert.AreEqual(expectedException, actualException); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs new file mode 100644 index 0000000000..c10a2fa8c0 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockFileServiceTestFixture.cs @@ -0,0 +1,101 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockFileServiceTestFixture + { + MockFileService fileService; + + [SetUp] + public void Init() + { + fileService = new MockFileService(); + } + + [Test] + public void FileOpenedReturnsNullByDefault() + { + Assert.IsNull(fileService.FileOpened); + } + + [Test] + public void FileOpenedReturnsFileNamePassedToOpenFileMethod() + { + fileService.OpenFile("test.cs"); + Assert.AreEqual("test.cs", fileService.FileOpened); + } + + [Test] + public void FilePositionsAreEqualWhenFileNameAndPositionAreEqual() + { + FilePosition lhs = new FilePosition("test.cs", 1, 2); + FilePosition rhs = new FilePosition("test.cs", 1, 2); + + Assert.AreEqual(lhs, rhs); + } + + [Test] + public void FilePositionEqualsReturnsFalseWhenNullPassed() + { + FilePosition lhs = new FilePosition("test.cs", 1, 2); + Assert.IsFalse(lhs.Equals(null)); + } + + [Test] + public void FilePositionsAreNotEqualWhenFileNamesAreNotEqual() + { + FilePosition lhs = new FilePosition("test1.cs", 1, 2); + FilePosition rhs = new FilePosition("test2.cs", 1, 2); + + Assert.AreNotEqual(lhs, rhs); + } + + [Test] + public void FilePositionsAreNotEqualWhenLinesAreNotEqual() + { + FilePosition lhs = new FilePosition("test.cs", 500, 2); + FilePosition rhs = new FilePosition("test.cs", 1, 2); + + Assert.AreNotEqual(lhs, rhs); + } + + [Test] + public void FilePositionsAreNotEqualWhenColumnsAreNotEqual() + { + FilePosition lhs = new FilePosition("test.cs", 1, 2000); + FilePosition rhs = new FilePosition("test.cs", 1, 2); + + Assert.AreNotEqual(lhs, rhs); + } + + [Test] + public void FilePositionJumpedToIsNullByDefault() + { + Assert.IsNull(fileService.FilePositionJumpedTo); + } + + [Test] + public void FilePositionJumpedToReturnsParametersPassedToJumpToFilePositionMethod() + { + int line = 1; + int col = 10; + string fileName = "test.cs"; + fileService.JumpToFilePosition(fileName, line, col); + + FilePosition expectedFilePos = new FilePosition(fileName, line, col); + + Assert.AreEqual(expectedFilePos, fileService.FilePositionJumpedTo); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs new file mode 100644 index 0000000000..a85f91cf77 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMessageServiceTestFixture.cs @@ -0,0 +1,69 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockMessageServiceTestFixture + { + MockMessageService messageService; + + [SetUp] + public void Init() + { + messageService = new MockMessageService(); + } + + [Test] + public void CaptionIsNullByDefault() + { + Assert.IsNull(messageService.Caption); + } + + [Test] + public void QuestionIsNullByDefault() + { + Assert.IsNull(messageService.Question); + } + + [Test] + public void QuestionIsSavedAfterAskQuestionMethodIsCalled() + { + string expectedQuestion = "question"; + messageService.AskQuestion(expectedQuestion, null); + + Assert.AreEqual(expectedQuestion, messageService.Question); + } + + [Test] + public void CaptionIsSavedAfterAskQuestionMethodIsCalled() + { + string expectedCaption = "caption"; + messageService.AskQuestion(null, expectedCaption); + + Assert.AreEqual(expectedCaption, messageService.Caption); + } + + [Test] + public void AskQuestionMethodReturnsFalseByDefault() + { + Assert.IsFalse(messageService.AskQuestion(null, null)); + } + + [Test] + public void AskQuestionMethodReturnsTrueWhenConfigured() + { + messageService.AskQuestionReturnValue = true; + Assert.IsTrue(messageService.AskQuestion(null, null)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs new file mode 100644 index 0000000000..6526562205 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockMethodTestFixture.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockMethodTestFixture + { + [Test] + public void DeclaringTypeReturnsExpectedClassWhenMethodCreated() + { + MockClass declaringType = new MockClass(); + MockMethod method = new MockMethod(declaringType); + Assert.AreEqual(declaringType, method.DeclaringType); + } + + [Test] + public void NameReturnsExpectedMethodNameWhenMethodCreated() + { + MockClass declaringType = new MockClass(); + MockMethod method = new MockMethod(declaringType, "MyMethod"); + Assert.AreEqual("MyMethod", method.Name); + } + + [Test] + public void FullyQualifiedNameReturnsFullyQualifiedMethodName() + { + MockClass declaringType = new MockClass("MyNamespace.MyClass"); + MockMethod method = new MockMethod(declaringType, "MyMethod"); + string expectedName = "MyNamespace.MyClass.MyMethod"; + Assert.AreEqual(expectedName, method.FullyQualifiedName); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestFrameworkTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestFrameworkTestFixture.cs new file mode 100644 index 0000000000..7cc2ae9a66 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestFrameworkTestFixture.cs @@ -0,0 +1,139 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockNUnitTestFrameworkTestFixture + { + MockRunTestCommandContext context; + MockProcessRunner processRunner; + MockNUnitTestFramework testFramework; + NUnitTestRunner testRunner; + NUnitTestDebugger testDebugger; + MockDebuggerService debuggerService; + + [SetUp] + public void Init() + { + context = new MockRunTestCommandContext(); + processRunner = new MockProcessRunner(); + debuggerService = new MockDebuggerService(); + + testFramework = new MockNUnitTestFramework(debuggerService, + processRunner, + context.MockTestResultsMonitor, + context.UnitTestingOptions, + context.MessageService); + + testRunner = testFramework.CreateTestRunner() as NUnitTestRunner; + testDebugger = testFramework.CreateTestDebugger() as NUnitTestDebugger; + } + + [Test] + public void CreateTestRunnerCreatesNUnitTestRunner() + { + Assert.IsNotNull(testRunner); + } + + [Test] + public void NUnitTestRunnerAddedToTestRunnersCreatedList() + { + List expectedRunners = new List(); + expectedRunners.Add(testRunner); + + Assert.AreEqual(expectedRunners.ToArray(), testFramework.NUnitTestRunnersCreated.ToArray()); + } + + [Test] + public void NUnitTestRunnerCreatedWithMockProcessRunnerAndUnitTestingOptions() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests tests = new SelectedTests(project); + testRunner.Start(tests); + + NUnitConsoleApplication app = new NUnitConsoleApplication(tests, context.UnitTestingOptions); + string expectedArguments = app.GetArguments(); + Assert.AreEqual(expectedArguments, processRunner.CommandArgumentsPassedToStartMethod); + } + + [Test] + public void NUnitTestRunnerCreatedWithMockTestResultsMonitor() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests tests = new SelectedTests(project); + testRunner.Start(tests); + + Assert.IsTrue(context.MockTestResultsMonitor.IsStartMethodCalled); + } + + [Test] + public void NUnitTestDebuggerCreated() + { + Assert.IsNotNull(testDebugger); + } + + [Test] + public void NUnitTestDebuggerAddedToTestDebuggersCreatedList() + { + List expectedDebuggers = new List(); + expectedDebuggers.Add(testDebugger); + + Assert.AreEqual(expectedDebuggers.ToArray(), testFramework.NUnitTestDebuggersCreated.ToArray()); + } + + [Test] + public void NUnitTestDebuggerCreatedWithMockTestResultsMonitor() + { + MockCSharpProject project = new MockCSharpProject(); + SelectedTests tests = new SelectedTests(project); + testDebugger.Start(tests); + + Assert.IsTrue(context.MockTestResultsMonitor.IsStartMethodCalled); + } + + [Test] + public void NUnitTestDebuggerCreatedWithDebuggerService() + { + context.UnitTestingOptions.NoShadow = true; + + MockCSharpProject project = new MockCSharpProject(); + SelectedTests tests = new SelectedTests(project); + testDebugger.Start(tests); + + NUnitConsoleApplication app = new NUnitConsoleApplication(tests, context.UnitTestingOptions); + string expectedArguments = app.GetArguments(); + Assert.AreEqual(expectedArguments, debuggerService.MockDebugger.ProcessStartInfo.Arguments); + } + + [Test] + public void NUnitTestDebuggerCreatedWithMessageService() + { + context.MockMessageService.AskQuestionReturnValue = true; + debuggerService.IsDebuggerLoaded = true; + debuggerService.MockDebugger.IsDebugging = true; + + MockCSharpProject project = new MockCSharpProject(); + SelectedTests tests = new SelectedTests(project); + testDebugger.Start(tests); + + Assert.IsNotNull(context.MockMessageService.Question); + } + + [Test] + public void IsBuildNeededBeforeTestRunReturnsTrue() + { + Assert.IsTrue(testFramework.IsBuildNeededBeforeTestRun); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestRunnerContextTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestRunnerContextTestFixture.cs new file mode 100644 index 0000000000..dd76a5de8e --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockNUnitTestRunnerContextTestFixture.cs @@ -0,0 +1,45 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockNUnitTestRunnerContextTestFixture + { + MockNUnitTestRunnerContext context; + + [SetUp] + public void Init() + { + context = new MockNUnitTestRunnerContext(); + } + + [Test] + public void MockProcessRunnerIsNotNull() + { + Assert.IsNotNull(context.MockProcessRunner); + } + + [Test] + public void MockTestResultsMonitorExists() + { + Assert.IsNotNull(context.MockTestResultsMonitor); + } + + [Test] + public void MockTestsResultsMonitorFileNameIsTmp66DotTmp() + { + string expectedFileName = @"c:\temp\tmp66.tmp"; + Assert.AreEqual(expectedFileName, context.MockTestResultsMonitor.FileName.ToString()); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProcessRunnerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProcessRunnerTestFixture.cs new file mode 100644 index 0000000000..946ed9c4d1 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProcessRunnerTestFixture.cs @@ -0,0 +1,121 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Util; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockProcessRunnerTestFixture + { + MockProcessRunner processRunner; + + [SetUp] + public void Init() + { + processRunner = new MockProcessRunner(); + } + + [Test] + public void LogStandardOutputAndErrorReturnsTrueByDefault() + { + Assert.IsTrue(processRunner.LogStandardOutputAndError); + } + + [Test] + public void LogStandardOutputAndErrorReturnsFalseIfSetToFalse() + { + processRunner.LogStandardOutputAndError = false; + Assert.IsFalse(processRunner.LogStandardOutputAndError); + } + + [Test] + public void CommandPassedToStartMethodReturnsNullByDefault() + { + Assert.IsNull(processRunner.CommandPassedToStartMethod); + } + + [Test] + public void CommandArgumentsPassedToStartMethodReturnsNullByDefault() + { + Assert.IsNull(processRunner.CommandArgumentsPassedToStartMethod); + } + + [Test] + public void CommandPassedToStartMethodIsNUnitConsoleExeAfterStartMethodIsCalled() + { + string command = "nunit-console.exe"; + processRunner.Start(command, null); + Assert.AreEqual(command, processRunner.CommandPassedToStartMethod); + } + + [Test] + public void CommandArgumentsPassedToStartMethodIsTestAfterStartMethodIsCalled() + { + string args = "test"; + processRunner.Start(null, args); + Assert.AreEqual(args, processRunner.CommandArgumentsPassedToStartMethod); + } + + [Test] + public void IsKillMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(processRunner.IsKillMethodCalled); + } + + [Test] + public void IsKillMethodCalledReturnsTrueAfterKillMethodCalled() + { + processRunner.Kill(); + Assert.IsTrue(processRunner.IsKillMethodCalled); + } + + [Test] + public void FireProcessExitedEventFiresEvent() + { + bool fired = false; + processRunner.ProcessExited += delegate (object o, EventArgs e) { + fired = true; + }; + processRunner.FireProcessExitedEvent(); + + Assert.IsTrue(fired); + } + + [Test] + public void FireOutputLineReceivedEventFiresEventAndReturnsExpectedLine() + { + LineReceivedEventArgs expectedEventArgs = null; + processRunner.OutputLineReceived += delegate (object o, LineReceivedEventArgs e) { + expectedEventArgs = e; + }; + string line = "test"; + LineReceivedEventArgs eventArgs = new LineReceivedEventArgs(line); + processRunner.FireOutputLineReceivedEvent(eventArgs); + + Assert.AreEqual(line, expectedEventArgs.Line); + } + + [Test] + public void FireErrorLineReceivedEventFiresEventAndReturnsExpectedLine() + { + LineReceivedEventArgs expectedEventArgs = null; + processRunner.ErrorLineReceived += delegate (object o, LineReceivedEventArgs e) { + expectedEventArgs = e; + }; + string line = "test"; + LineReceivedEventArgs eventArgs = new LineReceivedEventArgs(line); + processRunner.FireErrorLineReceivedEvent(eventArgs); + + Assert.AreEqual(line, expectedEventArgs.Line); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs new file mode 100644 index 0000000000..adfccf2ff7 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectContentTestFixture.cs @@ -0,0 +1,55 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockProjectContentTestFixture + { + MockProjectContent projectContent; + + [SetUp] + public void Init() + { + projectContent = new MockProjectContent(); + } + + [Test] + public void LanguageIsCSharpLanguage() + { + Assert.AreEqual(LanguageProperties.CSharp, projectContent.Language); + } + + [Test] + public void SystemTypesIsNotNull() + { + Assert.IsNotNull(projectContent.SystemTypes); + } + + [Test] + public void SystemObjectReturnTypeReturnedFromSystemTypesHasSystemObjectFullyQualifiedName() + { + string expectedName = "System.Object"; + IReturnType returnType = projectContent.SystemTypes.Object; + Assert.AreEqual(expectedName, returnType.FullyQualifiedName); + } + + [Test] + public void GetClassWithTypeParameterCountReturnsMockClassWithSpecifiedName() + { + string expectedName = "MyNamespace.MyTestClass"; + MockClass c = projectContent.GetClass(expectedName, 0) as MockClass; + Assert.AreEqual(expectedName, c.FullyQualifiedName); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectSaveTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectSaveTestFixture.cs new file mode 100644 index 0000000000..2a0fa5df53 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockProjectSaveTestFixture.cs @@ -0,0 +1,41 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockProjectSaveTestFixture + { + MockCSharpProject project; + + [SetUp] + public void Init() + { + project = new MockCSharpProject(); + project.FileName = @"e:\projects\myproj.csproj"; + } + + [Test] + public void IsSavedReturnsFalseByDefault() + { + Assert.IsFalse(project.IsSaved); + } + + [Test] + public void IsSavedReturnsTrueAfterSaveMethodCalled() + { + project.Save(); + Assert.IsTrue(project.IsSaved); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockRegisteredTestFrameworksTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockRegisteredTestFrameworksTestFixture.cs new file mode 100644 index 0000000000..3dae682242 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockRegisteredTestFrameworksTestFixture.cs @@ -0,0 +1,75 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockRegisteredTestFrameworksTestFixture + { + MockRegisteredTestFrameworks testFrameworks; + MockTestFramework testFramework; + MockCSharpProject project; + + [SetUp] + public void Init() + { + testFrameworks = new MockRegisteredTestFrameworks(); + + testFramework = new MockTestFramework(); + project = new MockCSharpProject(); + testFrameworks.AddTestFrameworkForProject(project, testFramework); + } + + [Test] + public void CreateTestRunnerForKnownProjectCreatesTestRunnerInKnownTestFramework() + { + ITestRunner testRunner = testFrameworks.CreateTestRunner(project); + ITestRunner expectedTestRunner = testFramework.TestRunnersCreated[0]; + Assert.AreEqual(expectedTestRunner, testRunner); + } + + [Test] + public void CreateTestRunnerReturnsNullForUnknownProject() + { + MockCSharpProject unknownProject = new MockCSharpProject(); + Assert.IsNull(testFrameworks.CreateTestRunner(unknownProject)); + } + + [Test] + public void GetTestFrameworkForProjectReturnsTestFrameworkForKnownProject() + { + Assert.AreEqual(testFramework, testFrameworks.GetTestFrameworkForProject(project)); + } + + [Test] + public void GetTestFrameworkForProjectReturnsTestFrameworkForUnknownProject() + { + MockCSharpProject unknownProject = new MockCSharpProject(); + Assert.IsNull(testFrameworks.GetTestFrameworkForProject(unknownProject)); + } + + [Test] + public void CreateTestDebuggerForKnownProjectCreatesTestDebuggerInKnownTestFramework() + { + ITestRunner testRunner = testFrameworks.CreateTestDebugger(project); + ITestRunner expectedTestRunner = testFramework.TestDebuggersCreated[0]; + Assert.AreEqual(expectedTestRunner, testRunner); + } + + [Test] + public void CreateTestDebuggerReturnsNullForUnknownProject() + { + MockCSharpProject unknownProject = new MockCSharpProject(); + Assert.IsNull(testFrameworks.CreateTestDebugger(unknownProject)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockRunTestCommandContextTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockRunTestCommandContextTestFixture.cs new file mode 100644 index 0000000000..5866245cae --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockRunTestCommandContextTestFixture.cs @@ -0,0 +1,80 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockRunTestCommandContextTestFixture + { + IRunTestCommandContext runTestCommandContext; + + [SetUp] + public void Init() + { + runTestCommandContext = new MockRunTestCommandContext(); + } + + [Test] + public void UnitTestingOptionsIsNotNull() + { + MockRunTestCommandContext context = new MockRunTestCommandContext(); + Assert.IsNotNull(context.UnitTestingOptions); + } + + [Test] + public void RegisteredTestFrameworksIsMockRegisteredTestFrameworks() + { + Assert.IsNotNull(runTestCommandContext.RegisteredTestFrameworks as MockRegisteredTestFrameworks); + } + + [Test] + public void TaskServiceIsMockTaskService() + { + Assert.IsNotNull(runTestCommandContext.TaskService as MockTaskService); + } + + [Test] + public void WorkbenchIsMockUnitTestWorkbench() + { + Assert.IsNotNull(runTestCommandContext.Workbench as MockUnitTestWorkbench); + } + + [Test] + public void BuildProjectFactoryIsMockBuildProjectFactory() + { + Assert.IsNotNull(runTestCommandContext.BuildProjectFactory as MockBuildProjectFactory); + } + + [Test] + public void BuildOptionsIsMockBuildOptions() + { + Assert.IsNotNull(runTestCommandContext.BuildOptions as MockBuildOptions); + } + + [Test] + public void UnitTestCategoryIsMessageViewWithCategoryNameUnitTests() + { + Assert.AreEqual("Unit Tests", runTestCommandContext.UnitTestCategory.Category); + } + + [Test] + public void UnitTestsPadIsMockUnitTestsPad() + { + Assert.IsNotNull(runTestCommandContext.OpenUnitTestsPad as MockUnitTestsPad); + } + + [Test] + public void MessageServiceIsMockMessageService() + { + Assert.IsNotNull(runTestCommandContext.MessageService as MockMessageService); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockSaveAllFilesCommandTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockSaveAllFilesCommandTestFixture.cs new file mode 100644 index 0000000000..cde4abc271 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockSaveAllFilesCommandTestFixture.cs @@ -0,0 +1,39 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockSaveAllFilesCommandTestFixture + { + MockSaveAllFilesCommand saveAllFilesCommand; + + [SetUp] + public void Init() + { + saveAllFilesCommand = new MockSaveAllFilesCommand(); + } + + [Test] + public void IsSaveAllFilesMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(saveAllFilesCommand.IsSaveAllFilesMethodCalled); + } + + [Test] + public void IsSaveAllFilesMethodCalledReturnsTrueAfterMethodIsCalled() + { + saveAllFilesCommand.SaveAllFiles(); + Assert.IsTrue(saveAllFilesCommand.IsSaveAllFilesMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTaskServiceTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTaskServiceTestFixture.cs new file mode 100644 index 0000000000..b648a6a9ca --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTaskServiceTestFixture.cs @@ -0,0 +1,102 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockTaskServiceTestFixture + { + MockTaskService taskService; + + [SetUp] + public void Init() + { + taskService = new MockTaskService(); + } + + [Test] + public void IsClearExceptCommentTasksMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(taskService.IsClearExceptCommentTasksMethodCalled); + } + + [Test] + public void IsClearExceptCommentTasksMethodCalledReturnsTrueAfterClearExceptCommentTasksMethodCalled() + { + taskService.ClearExceptCommentTasks(); + Assert.IsTrue(taskService.IsClearExceptCommentTasksMethodCalled); + } + + [Test] + public void IsInUpdateWhilstClearExceptCommentTasksMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(taskService.IsInUpdateWhilstClearExceptCommentTasksMethodCalled); + } + + [Test] + public void IsInUpdateWhilstClearExceptCommentTasksMethodCalledReturnsFalseWhenIsInUpdateIsFalseDuringMethodCall() + { + taskService.ClearExceptCommentTasks(); + Assert.IsFalse(taskService.IsInUpdateWhilstClearExceptCommentTasksMethodCalled); + } + + [Test] + public void IsInUpdateWhilstClearExceptCommentTasksMethodCalledReturnsTrueWhenIsInUpdateIsTrueDuringMethodCall() + { + taskService.InUpdate = true; + taskService.ClearExceptCommentTasks(); + Assert.IsTrue(taskService.IsInUpdateWhilstClearExceptCommentTasksMethodCalled); + } + + [Test] + public void SomethingWentWrongReturnsFalseByDefault() + { + Assert.IsFalse(taskService.SomethingWentWrong); + } + + [Test] + public void SomethingWentWrongReturnsTrueWhenErrorTaskAddedToTaskService() + { + FileName fileName = new FileName("test.cs"); + Task task = new Task(fileName, String.Empty, 1, 2, TaskType.Error); + taskService.Add(task); + Assert.IsTrue(taskService.SomethingWentWrong); + } + + [Test] + public void SomethingWentWrongReturnsTrueWhenWarningTaskAddedToTaskService() + { + FileName fileName = new FileName("test.cs"); + Task task = new Task(fileName, String.Empty, 1, 2, TaskType.Warning); + taskService.Add(task); + Assert.IsTrue(taskService.SomethingWentWrong); + } + + [Test] + public void NoTasksAddedToTaskServiceByDefault() + { + Assert.AreEqual(0, taskService.Tasks.Count); + } + + [Test] + public void TasksAddedToTaskServiceAreSaved() + { + FileName fileName = new FileName("test.cs"); + Task task = new Task(fileName, "description", 1, 1, TaskType.Error); + taskService.Add(task); + + Task[] tasks = new Task[] { task }; + + Assert.AreEqual(tasks, taskService.Tasks.ToArray()); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkFactoryTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkFactoryTestFixture.cs new file mode 100644 index 0000000000..c779c5a86d --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkFactoryTestFixture.cs @@ -0,0 +1,55 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockObjectCreatorTestFixture + { + MockTestFrameworkFactory factory; + MockTestFramework myTestFramework; + + [SetUp] + public void Init() + { + factory = new MockTestFrameworkFactory(); + myTestFramework = new MockTestFramework(); + factory.Add("MyClass", myTestFramework); + } + + [Test] + public void CreateMethodPassedMyClassNameReturnsMyTestFramework() + { + Assert.AreSame(myTestFramework, factory.Create("MyClass")); + } + + [Test] + public void CreateMethodPassedUnknownClassNameReturnNull() + { + Assert.IsNull(factory.Create("Unknown")); + } + + [Test] + public void ClassNamesPassedToCreateAreRecorded() + { + List expectedClassNames = new List(); + expectedClassNames.Add("a"); + expectedClassNames.Add("b"); + expectedClassNames.Add("c"); + + factory.Create("a"); + factory.Create("b"); + factory.Create("c"); + + Assert.AreEqual(expectedClassNames, factory.ClassNamesPassedToCreateMethod); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs new file mode 100644 index 0000000000..dbb3b594e6 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworkTestFixture.cs @@ -0,0 +1,160 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockTestFrameworkTestFixture + { + MockTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new MockTestFramework(); + } + + [Test] + public void IsTestMethodReturnsFalseByDefault() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + Assert.IsFalse(testFramework.IsTestMethod(method)); + } + + [Test] + public void IsTestMethodIMemberParameterIsInitiallyNull() + { + Assert.IsNull(testFramework.IsTestMethodMemberParameterUsed); + } + + [Test] + public void IsTestMethodCallRecorded() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + testFramework.IsTestMethod(method); + Assert.AreEqual(method, testFramework.IsTestMethodMemberParameterUsed); + } + + [Test] + public void IsTestMethodReturnsTrueIfMethodMatchesMethodPreviouslySpecified() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + testFramework.AddTestMethod(method); + + Assert.IsTrue(testFramework.IsTestMethod(method)); + } + + [Test] + public void IsTestClassReturnsFalseByDefault() + { + MockClass c = new MockClass(); + Assert.IsFalse(testFramework.IsTestClass(c)); + } + + [Test] + public void IsTestClassReturnsTrueIfClassMatchesClassPreviouslySpecified() + { + MockClass c = new MockClass(); + testFramework.AddTestClass(c); + + Assert.IsTrue(testFramework.IsTestClass(c)); + } + + [Test] + public void IsTestClassIClassParameterIsInitiallyNull() + { + Assert.IsNull(testFramework.IsTestClassParameterUsed); + } + + [Test] + public void IsTestClassCallRecorded() + { + MockClass c = new MockClass(); + testFramework.IsTestClass(c); + Assert.AreEqual(c, testFramework.IsTestClassParameterUsed); + } + + [Test] + public void IsTestProjectReturnsFalseByDefault() + { + MockCSharpProject project = new MockCSharpProject(); + Assert.IsFalse(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsTrueIfProjectMatchesProjectPreviouslySpecified() + { + MockCSharpProject project = new MockCSharpProject(); + testFramework.AddTestProject(project); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectIProjectParameterIsInitiallyNull() + { + Assert.IsNull(testFramework.IsTestProjectParameterUsed); + } + + [Test] + public void IsTestProjectallRecorded() + { + MockCSharpProject project = new MockCSharpProject(); + testFramework.IsTestProject(project); + Assert.AreEqual(project, testFramework.IsTestProjectParameterUsed); + } + + [Test] + public void IsTestClassReturnsFalseAfterTestClassRemovedFromTestFramework() + { + MockClass c = new MockClass(); + testFramework.AddTestClass(c); + testFramework.RemoveTestClass(c); + + Assert.IsFalse(testFramework.IsTestClass(c)); + } + + [Test] + public void CreateTestRunnerReturnsNewMockTestRunner() + { + Assert.IsInstanceOf(typeof(MockTestRunner), testFramework.CreateTestRunner()); + } + + [Test] + public void TestRunnersCreatedReturnsTestRunnersCreatedByCallingCreateTestRunnerMethod() + { + List expectedRunners = new List(); + expectedRunners.Add(testFramework.CreateTestRunner()); + expectedRunners.Add(testFramework.CreateTestRunner()); + + Assert.AreEqual(expectedRunners.ToArray(), testFramework.TestRunnersCreated.ToArray()); + } + + [Test] + public void TestDebuggersCreatedReturnsTestRunnersCreatedByCallingCreateTestDebuggerMethod() + { + List expectedRunners = new List(); + expectedRunners.Add(testFramework.CreateTestDebugger()); + expectedRunners.Add(testFramework.CreateTestDebugger()); + + Assert.AreEqual(expectedRunners.ToArray(), testFramework.TestDebuggersCreated.ToArray()); + } + + [Test] + public void IsBuildNeededBeforeTestRunReturnsTrueByDefault() + { + Assert.IsTrue(testFramework.IsBuildNeededBeforeTestRun); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworksWithNUnitFrameworkSupportTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworksWithNUnitFrameworkSupportTestFixture.cs new file mode 100644 index 0000000000..7d76a40545 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestFrameworksWithNUnitFrameworkSupportTestFixture.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockTestFrameworksWithNUnitFrameworkSupportTestFixture + { + MockTestFrameworksWithNUnitFrameworkSupport testFrameworks; + + [SetUp] + public void Init() + { + testFrameworks = new MockTestFrameworksWithNUnitFrameworkSupport(); + } + + [Test] + public void ImplementsIRegisteredTestFrameworkInterface() + { + Assert.IsNotNull(testFrameworks as IRegisteredTestFrameworks); + } + + [Test] + public void IsNUnitTestFramework() + { + Assert.IsInstanceOf(typeof(NUnitTestFramework), testFrameworks); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestResultsMonitorTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestResultsMonitorTestFixture.cs new file mode 100644 index 0000000000..416bf54cee --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestResultsMonitorTestFixture.cs @@ -0,0 +1,114 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockTestResultsMonitorTestFixture + { + MockTestResultsMonitor testResultsMonitor; + + [SetUp] + public void Init() + { + testResultsMonitor = new MockTestResultsMonitor(); + } + + [Test] + public void IsStopMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(testResultsMonitor.IsStopMethodCalled); + } + + [Test] + public void IsStopMethodCalledReturnsTrueAfterStopMethodCalled() + { + testResultsMonitor.Stop(); + Assert.IsTrue(testResultsMonitor.IsStopMethodCalled); + } + + [Test] + public void IsStopMethodCalledCanBeResetAfterStopMethodIsCalled() + { + testResultsMonitor.Stop(); + testResultsMonitor.IsStopMethodCalled = false; + Assert.IsFalse(testResultsMonitor.IsStopMethodCalled); + } + + [Test] + public void IsDisposeMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(testResultsMonitor.IsDisposeMethodCalled); + } + + [Test] + public void IsDisposeMethodCalledReturnsTrueAfterStopMethodCalled() + { + testResultsMonitor.Dispose(); + Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled); + } + + [Test] + public void IsStartMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(testResultsMonitor.IsStartMethodCalled); + } + + [Test] + public void IsStopMethodCalledReturnsTrueAfterStartMethodCalled() + { + testResultsMonitor.Start(); + Assert.IsTrue(testResultsMonitor.IsStartMethodCalled); + } + + [Test] + public void FileNamePropertyReturnsNullByDefault() + { + Assert.IsNull(testResultsMonitor.FileName); + } + + [Test] + public void FileNamePropertyReturnsFileNameSet() + { + testResultsMonitor.FileName = "test.xml"; + Assert.AreEqual("test.xml", testResultsMonitor.FileName); + } + + [Test] + public void FireTestFinishedEventTriggersTestFinishedEvent() + { + TestResult expectedResult = new TestResult("abc"); + TestResult result = null; + testResultsMonitor.TestFinished += + delegate(object source, TestFinishedEventArgs e) { + result = e.Result; + }; + + testResultsMonitor.FireTestFinishedEvent(expectedResult); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void IsReadMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(testResultsMonitor.IsReadMethodCalled); + } + + [Test] + public void IsReadMethodCalledReturnsTrueAfterReadMethodCalled() + { + testResultsMonitor.Read(); + Assert.IsTrue(testResultsMonitor.IsReadMethodCalled); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestRunnerTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestRunnerTestFixture.cs new file mode 100644 index 0000000000..4b8a365b75 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockTestRunnerTestFixture.cs @@ -0,0 +1,125 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockTestRunnerTestFixture + { + MockTestRunner testRunner; + + [SetUp] + public void Init() + { + testRunner = new MockTestRunner(); + } + + [Test] + public void IsDisposeCalledReturnsTrueAfterDisposeMethodCalled() + { + testRunner.Dispose(); + Assert.IsTrue(testRunner.IsDisposeCalled); + } + + [Test] + public void IsDisposeCalledReturnsFalseByDefault() + { + Assert.IsFalse(testRunner.IsDisposeCalled); + } + + [Test] + public void IsStartCalledReturnsTrueAfterStartMethodCalled() + { + SelectedTests selectedTests = new SelectedTests(null); + testRunner.Start(selectedTests); + Assert.IsTrue(testRunner.IsStartCalled); + } + + [Test] + public void IsStartCalledReturnsFalseByDefault() + { + Assert.IsFalse(testRunner.IsStartCalled); + } + + [Test] + public void IsStopCalledReturnsTrueAfterStartMethodCalled() + { + testRunner.Stop(); + Assert.IsTrue(testRunner.IsStopCalled); + } + + [Test] + public void IsStopCalledReturnsFalseByDefault() + { + Assert.IsFalse(testRunner.IsStopCalled); + } + + [Test] + public void FireTestFinishedEventTriggersTestFinishedEvent() + { + TestResult expectedResult = new TestResult("abc"); + TestResult result = null; + testRunner.TestFinished += + delegate(object source, TestFinishedEventArgs e) { + result = e.Result; + }; + + testRunner.FireTestFinishedEvent(expectedResult); + + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void SelectedTestsPassedToStartMethodIsNullByDefault() + { + Assert.IsNull(testRunner.SelectedTestsPassedToStartMethod); + } + + [Test] + public void SelectedTestsPassedToStartMethodIsSaved() + { + SelectedTests expectedSelectedTests = new SelectedTests(null); + testRunner.Start(expectedSelectedTests); + + Assert.AreEqual(expectedSelectedTests, testRunner.SelectedTestsPassedToStartMethod); + } + + [Test] + public void FireAllTestFinishedsEventTriggersAllTestsFinishedEvent() + { + bool fired = false; + testRunner.AllTestsFinished += + delegate(object source, EventArgs e) { + fired = true; + }; + + testRunner.FireAllTestsFinishedEvent(); + + Assert.IsTrue(fired); + } + + [Test] + public void FireMessageReceivedEventTriggersMessageReceivedEvent() + { + string message = null; + testRunner.MessageReceived += + delegate(object source, MessageReceivedEventArgs e) { + message = e.Message; + }; + + string expectedMessage = "test"; + testRunner.FireMessageReceivedEvent(expectedMessage); + + Assert.AreEqual(expectedMessage, message); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockUnitTestWorkbenchTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockUnitTestWorkbenchTestFixture.cs new file mode 100644 index 0000000000..a1f268ea3f --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockUnitTestWorkbenchTestFixture.cs @@ -0,0 +1,144 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockUnitTestWorkbenchTestFixture + { + MockUnitTestWorkbench workbench; + TestResult resultShown; + bool testAsyncMethodCalled; + + [SetUp] + public void Init() + { + workbench = new MockUnitTestWorkbench(); + } + + [Test] + public void GetPadReturnsNullForUnknownType() + { + Assert.IsNull(workbench.GetPad(typeof(String))); + } + + [Test] + public void NoActionsPassedToSafeThreadAsyncCallMethod() + { + Assert.AreEqual(0, workbench.SafeThreadAsyncMethodCalls.Count); + } + + [Test] + public void MethodStoredInSafeThreadAsyncMethodCallsCollectionAfterSafeThreadAsyncCallMethodCalled() + { + workbench.SafeThreadAsyncCall(this.MethodStoredInSafeThreadAsyncMethodCallsCollectionAfterSafeThreadAsyncCallMethodCalled); + + Action action = this.MethodStoredInSafeThreadAsyncMethodCallsCollectionAfterSafeThreadAsyncCallMethodCalled; + Assert.AreEqual(action, workbench.SafeThreadAsyncMethodCalls[0]); + } + + [Test] + public void MethodWithParameterStoredInSafeThreadAsyncMethodCallsCollectionAfterSafeThreadAsyncCallMethodCalled() + { + TestResult result = new TestResult("abc"); + workbench.SafeThreadAsyncCall(this.ShowResults, result); + + ActionArguments actionArgs = new ActionArguments(); + actionArgs.Action = this.ShowResults; + actionArgs.Arg = result; + + Assert.AreEqual(actionArgs, workbench.SafeThreadAsyncMethodCallsWithArguments[0]); + } + + void ShowResults(TestResult result) + { + resultShown = result; + } + + [Test] + public void SafeThreadAsyncCallWillCallActualMethodIfMakeMethodCallsSetToTrue() + { + TestResult result = new TestResult("abc"); + workbench.MakeSafeThreadAsyncMethodCallsWithArguments = true; + workbench.SafeThreadAsyncCall(this.ShowResults, result); + + Assert.AreEqual(result, resultShown); + } + + [Test] + public void NonGenericSafeThreadAsyncCallWillCallActualMethodIfMakeMethodCallsSetToTrue() + { + workbench.MakeNonGenericSafeThreadAsyncMethodCalls = true; + workbench.SafeThreadAsyncCall(this.TestAsyncCallMethod); + + Assert.IsTrue(testAsyncMethodCalled); + } + + void TestAsyncCallMethod() + { + testAsyncMethodCalled = true; + } + + [Test] + public void MakeMethodCallsIsFalseByDefault() + { + Assert.IsFalse(workbench.MakeSafeThreadAsyncMethodCallsWithArguments); + } + + [Test] + public void TypesPassedToGetPadMethodReturnsEmptyCollectionByDefault() + { + Assert.AreEqual(0, workbench.TypesPassedToGetPadMethod.Count); + } + + [Test] + public void ErrorListTypeStoredInTypesPassedToGetPadMethod() + { + workbench.GetPad(typeof(ErrorListPad)); + Type[] expectedTypes = new Type[] { typeof(ErrorListPad) }; + + Assert.AreEqual(expectedTypes, workbench.TypesPassedToGetPadMethod.ToArray()); + } + + [Test] + public void CompilerMessageViewPadExistsInWorkbench() + { + PadDescriptor actualPadDescriptor = workbench.GetPad(typeof(CompilerMessageView)); + Assert.IsNotNull(actualPadDescriptor); + } + + [Test] + public void ErrorListPadExistsInWorkbench() + { + PadDescriptor actualPadDescriptor = workbench.GetPad(typeof(ErrorListPad)); + Assert.IsNotNull(actualPadDescriptor); + } + + [Test] + public void ErrorListPadDescriptorPropertyReturnsErrorListPad() + { + string expectedTypeName = typeof(ErrorListPad).FullName; + string typeName = workbench.ErrorListPadDescriptor.Class; + Assert.AreEqual(expectedTypeName, typeName); + } + + [Test] + public void CompilerMessageViewPadDescriptorPropertyReturnsCompilerMessageViewPad() + { + string expectedTypeName = typeof(CompilerMessageView).FullName; + string typeName = workbench.CompilerMessageViewPadDescriptor.Class; + Assert.AreEqual(expectedTypeName, typeName); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockUnitTestsPadTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockUnitTestsPadTestFixture.cs new file mode 100644 index 0000000000..f5fca27531 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/MockUnitTestsPadTestFixture.cs @@ -0,0 +1,108 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class MockUnitTestsPadTestFixture + { + MockUnitTestsPad pad; + + [SetUp] + public void Init() + { + pad = new MockUnitTestsPad(); + } + + [Test] + public void IsUpdateToolbarMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(pad.IsUpdateToolbarMethodCalled); + } + + [Test] + public void IsUpdateToolbarMethodCalledReturnsTrueAfterUpdateToolbarMethodIsCalled() + { + pad.UpdateToolbar(); + Assert.IsTrue(pad.IsUpdateToolbarMethodCalled); + } + + [Test] + public void CanResetIsUpdateToolbarMethodAfterUpdateToolbarMethodIsCalled() + { + pad.UpdateToolbar(); + pad.IsUpdateToolbarMethodCalled = false; + Assert.IsFalse(pad.IsUpdateToolbarMethodCalled); + } + + [Test] + public void IsBringToFrontMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(pad.IsBringToFrontMethodCalled); + } + + [Test] + public void IsBringToFrontMethodCalledReturnsTrueAfterBringToFrontMethodIsCalled() + { + pad.BringToFront(); + Assert.IsTrue(pad.IsBringToFrontMethodCalled); + } + + [Test] + public void IsResetTestResultsMethodCalledReturnsFalseByDefault() + { + Assert.IsFalse(pad.IsResetTestResultsMethodCalled); + } + + [Test] + public void IsResetTestResultsMethodCalledReturnsTrueAfterResetTestResultsMethodIsCalled() + { + pad.ResetTestResults(); + Assert.IsTrue(pad.IsResetTestResultsMethodCalled); + } + + [Test] + public void GetProjectsReturnsNoProjectsByDefault() + { + Assert.AreEqual(0, pad.GetProjects().Length); + } + + [Test] + public void GetProjectsReturnsProjectsAddedToMockUnitTestsPad() + { + MockCSharpProject project = new MockCSharpProject(); + pad.AddProject(project); + + IProject[] expectedProjects = new IProject[] { project }; + + Assert.AreEqual(expectedProjects, pad.GetProjects()); + } + + [Test] + public void GetTestProjectReturnsNullForUnknownProject() + { + Assert.IsNull(pad.GetTestProject(new MockCSharpProject())); + } + + [Test] + public void GetTestProjectReturnsTestProjectForProject() + { + MockCSharpProject project = new MockCSharpProject(); + TestProject testProject = new TestProject(project, new MockProjectContent(), new MockRegisteredTestFrameworks()); + pad.AddTestProject(testProject); + + Assert.AreEqual(testProject, pad.GetTestProject(project)); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/SelectedTestsWithTestMethodTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/SelectedTestsWithTestMethodTestFixture.cs new file mode 100644 index 0000000000..d5d3a996a4 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/SelectedTestsWithTestMethodTestFixture.cs @@ -0,0 +1,51 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class SelectedTestsWithTestMethodTestFixture + { + SelectedTests selectedTestsWithTestMethod; + + [SetUp] + public void Init() + { + selectedTestsWithTestMethod = SelectedTestsHelper.CreateSelectedTestMethod(); + } + + [Test] + public void SelectedTestsHasProjectSelected() + { + Assert.IsNotNull(selectedTestsWithTestMethod.Project); + } + + [Test] + public void SelectedTestsHasOneProjectSelected() + { + Assert.AreEqual(1, selectedTestsWithTestMethod.Projects.Count); + } + + [Test] + public void SelectedTestsHasClassWithDotNetNameMyTestsMyTestClass() + { + Assert.AreEqual("MyTests.MyTestClass", selectedTestsWithTestMethod.Class.DotNetName); + } + + [Test] + public void SelectedTestsHasMethodWithNameMyTestMethod() + { + Assert.AreEqual("MyTestMethod", selectedTestsWithTestMethod.Method.Name); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs new file mode 100644 index 0000000000..d7ce0148b1 --- /dev/null +++ b/src/AddIns/Analysis/UnitTesting/Test/Utils/Tests/TaskComparisonTestFixture.cs @@ -0,0 +1,211 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using NUnit.Framework; +using UnitTesting.Tests.Utils; + +namespace UnitTesting.Tests.Utils.Tests +{ + [TestFixture] + public class TaskComparisonTestFixture + { + TaskComparison taskComparison; + Task lhs; + Task rhs; + int column = 20; + int line = 5; + string myTestFileName = @"c:\projects\tests\mytest.cs"; + string description = "description"; + + [SetUp] + public void Init() + { + FileName fileName = new FileName(myTestFileName); + lhs = new Task(fileName, description, column, line, TaskType.Error); + rhs = new Task(fileName, description, column, line, TaskType.Error); + } + + [Test] + public void IsMatchReturnsTrueWhenFileNameDescriptionColumnLineAndTaskTypeMatch() + { + CreateTaskComparison(); + Assert.IsTrue(taskComparison.IsMatch); + } + + void CreateTaskComparison() + { + taskComparison = new TaskComparison(lhs, rhs); + } + + [Test] + public void IsMatchReturnsFalseWhenTaskTypesAreDifferent() + { + FileName fileName = new FileName(myTestFileName); + lhs = new Task(fileName, description, column, line, TaskType.Warning); + CreateTaskComparison(); + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesTaskTypeMismatchWhenTaskTypesAreDifferent() + { + IsMatchReturnsFalseWhenTaskTypesAreDifferent(); + + string expectedMismatchReason = + "TaskTypes are different.\r\n" + + "Expected: Warning\r\n" + + "But was: Error\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + + [Test] + public void IsMatchReturnsFalseWhenFileNamesAreDifferent() + { + FileName fileName = new FileName(@"temp.cs"); + lhs = new Task(fileName, rhs.Description, rhs.Column, rhs.Line, rhs.TaskType); + CreateTaskComparison(); + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesFileNameMismatchWhenFileNamesAreDifferent() + { + IsMatchReturnsFalseWhenFileNamesAreDifferent(); + + string expectedMismatchReason = + "FileNames are different.\r\n" + + "Expected: temp.cs\r\n" + + "But was: c:\\projects\\tests\\mytest.cs\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + + [Test] + public void TaskComparisonIsMatchReturnsTrueWhenBothTasksAreNull() + { + lhs = null; + rhs = null; + CreateTaskComparison(); + + Assert.IsTrue(taskComparison.IsMatch); + } + + [Test] + public void IsMatchReturnsFalseWhenLhsTaskIsNull() + { + lhs = null; + CreateTaskComparison(); + + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesLhsTaskIsNullInComparison() + { + IsMatchReturnsFalseWhenLhsTaskIsNull(); + + string expectedMismatchReason = + "One task is null.\r\n" + + "Expected: (null)\r\n" + + "But was: " + rhs.ToString() + "\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + + [Test] + public void IsMatchReturnsFalseWhenRhsTaskIsNull() + { + rhs = null; + CreateTaskComparison(); + + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesRhsTaskIsNullInComparison() + { + IsMatchReturnsFalseWhenRhsTaskIsNull(); + + string expectedMismatchReason = + "One task is null.\r\n" + + "Expected: " + lhs.ToString() + "\r\n" + + "But was: (null)\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + + [Test] + public void IsMatchReturnsFalseWhenDescriptionsAreDifferent() + { + FileName fileName = new FileName(myTestFileName); + rhs = new Task(fileName, "different", column, line, TaskType.Error); + CreateTaskComparison(); + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesDescriptionMismatchWhenDescriptionsAreDifferent() + { + IsMatchReturnsFalseWhenDescriptionsAreDifferent(); + + string expectedMismatchReason = + "Descriptions are different.\r\n" + + "Expected: description\r\n" + + "But was: different\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + + [Test] + public void IsMatchReturnsFalseWhenColumnsAreDifferent() + { + FileName fileName = new FileName(myTestFileName); + rhs = new Task(fileName, description, 500, line, TaskType.Error); + CreateTaskComparison(); + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesColumnsMismatchWhenColumnsAreDifferent() + { + IsMatchReturnsFalseWhenColumnsAreDifferent(); + + string expectedMismatchReason = + "Columns are different.\r\n" + + "Expected: 20\r\n" + + "But was: 500\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + + [Test] + public void IsMatchReturnsFalseWhenLinesAreDifferent() + { + FileName fileName = new FileName(myTestFileName); + rhs = new Task(fileName, description, column, 66, TaskType.Error); + CreateTaskComparison(); + Assert.IsFalse(taskComparison.IsMatch); + } + + [Test] + public void MismatchReasonIndicatesLinesMismatchWhenColumnsAreDifferent() + { + IsMatchReturnsFalseWhenLinesAreDifferent(); + + string expectedMismatchReason = + "Lines are different.\r\n" + + "Expected: 5\r\n" + + "But was: 66\r\n"; + + Assert.AreEqual(expectedMismatchReason, taskComparison.MismatchReason); + } + } +} diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.addin b/src/AddIns/Analysis/UnitTesting/UnitTesting.addin index 9596e8d66f..0c32fe92dc 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.addin +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.addin @@ -1,41 +1,48 @@ - + - + - - - + + + + - - + + - - + + - - + + - - + + + + + + @@ -44,18 +51,18 @@ - + - + - - + + @@ -64,17 +71,17 @@ - + - + - + @@ -82,14 +89,14 @@ - + - + @@ -97,36 +104,36 @@ - - + + - + - - + + - + @@ -134,34 +141,27 @@ - + - + - + - + - @@ -173,10 +173,10 @@ - + @@ -186,28 +186,27 @@ - + - + - + label="${res:ICSharpCode.NUnitPad.NUnitPadContent.PadName}" + class="ICSharpCode.UnitTesting.UnitTestingOptionsPanel"/> diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj index 8cedcf9133..3543d1d00f 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.csproj @@ -1,4 +1,5 @@ - + + Library ICSharpCode.UnitTesting @@ -56,6 +57,16 @@ + + + + + + + + + + @@ -63,13 +74,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + Configuration\GlobalAssemblyInfo.cs @@ -117,11 +167,6 @@ ICSharpCode.Core False - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} diff --git a/src/AddIns/Analysis/UnitTesting/UnitTesting.sln b/src/AddIns/Analysis/UnitTesting/UnitTesting.sln index 79a6a60a1f..67a98ff275 100644 --- a/src/AddIns/Analysis/UnitTesting/UnitTesting.sln +++ b/src/AddIns/Analysis/UnitTesting/UnitTesting.sln @@ -1,7 +1,7 @@  -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -# SharpDevelop 3.0.0.2745 +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +# SharpDevelop 4.0.0.5840 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}" @@ -18,8 +18,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactory", "..\..\..\Libr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Widgets", "..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj", "{8035765F-D51F-4A0C-A746-2FD100E19419}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsUI", "..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj", "{D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -58,9 +56,5 @@ Global {8035765F-D51F-4A0C-A746-2FD100E19419}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.Build.0 = Release|Any CPU {8035765F-D51F-4A0C-A746-2FD100E19419}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.Build.0 = Release|Any CPU - {D3C782BA-178E-4235-A3BA-8C11DEBB6BEE}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj b/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj index 7e73ccbc05..cec7174312 100644 --- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj +++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/BooBinding.csproj @@ -1,4 +1,5 @@ - + + Library Grunwald.BooBinding @@ -131,11 +132,6 @@ NRefactory False - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {DBCF20A1-BA13-4582-BFA9-74DE4D987B73} NRefactoryToBooConverter diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs index 2190e2a846..f151030e52 100644 --- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs +++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooAdvancedHighlighter.cs @@ -14,8 +14,6 @@ using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; -using ICSharpCode.TextEditor; -using ICSharpCode.TextEditor.Document; namespace Grunwald.BooBinding.CodeCompletion { diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs index c4cc233220..dfa2ea7fd8 100644 --- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs +++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/CodeCompletion/BooParser.cs @@ -79,9 +79,12 @@ namespace Grunwald.BooBinding.CodeCompletion } } lineLength[i] = length; - BooCompiler compiler = new BooCompiler(); - compiler.Parameters.Input.Add(new StringInput(fileName, fileContent)); - ICompilationUnit cu = Parse(projectContent, fileName, lineLength, compiler); + ICompilationUnit cu; + lock (typeof(BooCompiler)) { + BooCompiler compiler = new BooCompiler(); + compiler.Parameters.Input.Add(new StringInput(fileName, fileContent)); + cu = Parse(projectContent, fileName, lineLength, compiler); + } AddCommentsAndRegions(cu, fileContent, fileName); return cu; } diff --git a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs index 6ca5b050e4..749ac8b589 100644 --- a/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs +++ b/src/AddIns/BackendBindings/Boo/BooBinding/Project/Src/Designer/BooDesignerLoader.cs @@ -18,7 +18,6 @@ using ICSharpCode.Core; using ICSharpCode.FormsDesigner; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Dom; -using ICSharpCode.TextEditor; namespace Grunwald.BooBinding.Designer { diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj index 5a01c5d831..4a7dfbc62d 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj @@ -87,11 +87,6 @@ ICSharpCode.AvalonEdit False - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} NRefactory diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs index dfae97e7e9..2290ebbc5f 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs @@ -79,17 +79,16 @@ namespace CSharpBinding return base.GetDefaultItemType(fileName); } - public override void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) + public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) { if (this.MinimumSolutionVersion == Solution.SolutionVersionVS2005) { MSBuildEngine.StartBuild(this, - buildServices, options, feedbackSink, MSBuildEngine.AdditionalTargetFiles.Concat( new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") })); } else { - base.StartBuild(buildServices, options, feedbackSink); + base.StartBuild(options, feedbackSink); } } diff --git a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs index 09ae65569a..6a08bfcbcc 100644 --- a/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs +++ b/src/AddIns/BackendBindings/CppBinding/CppBinding/Project/CppProject.cs @@ -2,12 +2,13 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using Microsoft.Build.Construction; + using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Internal.Templates; using ICSharpCode.SharpDevelop.Project; -using System.Diagnostics; +using Microsoft.Build.Construction; +using Microsoft.Build.Exceptions; namespace ICSharpCode.CppBinding.Project { @@ -16,10 +17,15 @@ namespace ICSharpCode.CppBinding.Project public CppProject(ProjectCreateInformation info) : base(info) { - AddImport(DefaultPropsFile, null); - AddImport(PropsFile, null); - AddImport(DefaultTargetsFile, null); - AddProjectConfigurationsItemGroup(); + try { + AddImport(DefaultPropsFile, null); + AddImport(PropsFile, null); + AddImport(DefaultTargetsFile, null); + AddProjectConfigurationsItemGroup(); + base.ReevaluateIfNecessary(); // provoke exception if import is invalid + } catch (InvalidProjectFileException ex) { + throw new ProjectLoadException("Please ensure that the Windows SDK is installed on your computer.\n\n" + ex.Message, ex); + } } public CppProject(ProjectLoadInformation info) @@ -60,7 +66,7 @@ namespace ICSharpCode.CppBinding.Project string outputPath = GetEvaluatedProperty("OutDir") ?? ""; if (!Path.IsPathRooted(outputPath)) return FileUtility.NormalizePath(Path.Combine(Path.Combine(Path.Combine(Directory, ".."), outputPath), - AssemblyName + GetExtension(OutputType))); + AssemblyName + GetExtension(OutputType))); else { // this will be valid if there is an explicit OutDir property in vcxproj file. @@ -83,11 +89,11 @@ namespace ICSharpCode.CppBinding.Project string extension = Path.GetExtension(fileName).ToLower(); switch (extension) { - case ".cpp": return ItemType.ClCompile; - case ".c": return ItemType.ClCompile; - case ".hpp": return ItemType.ClInclude; - case ".h": return ItemType.ClInclude; - case ".rc": return new ItemType(RESOURCE_COMPILE); + case ".cpp": return ItemType.ClCompile; + case ".c": return ItemType.ClCompile; + case ".hpp": return ItemType.ClInclude; + case ".h": return ItemType.ClInclude; + case ".rc": return new ItemType(RESOURCE_COMPILE); } return base.GetDefaultItemType(fileName); } @@ -162,7 +168,7 @@ namespace ICSharpCode.CppBinding.Project return result; } - public IList GetProjectUndefines(string fileName) + public IList GetProjectUndefines(string fileName) { if (fileName == null) throw new ArgumentNullException("fileName"); diff --git a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj index ce5a5dc2ed..bbac3c6b46 100644 --- a/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj +++ b/src/AddIns/BackendBindings/FSharpBinding/FSharpBinding.csproj @@ -1,4 +1,5 @@ - + + {E954F3CB-A446-492F-A664-2B376EBC86E8} Debug @@ -75,11 +76,6 @@ - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {2748AD25-9C63-4E12-877B-4DCE96FBED54} ICSharpCode.SharpDevelop diff --git a/src/AddIns/BackendBindings/Python/PythonBinding.sln b/src/AddIns/BackendBindings/Python/PythonBinding.sln index c0bb7b11c1..132066a9ec 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding.sln +++ b/src/AddIns/BackendBindings/Python/PythonBinding.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 -# SharpDevelop 4.0.0.5293 +# SharpDevelop 4.0.0.5840 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}" @@ -30,6 +30,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.SharpDevelop.Wi EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvalonEdit.AddIn", "..\..\DisplayBindings\AvalonEdit.AddIn\AvalonEdit.AddIn.csproj", "{0162E499-42D0-409B-AA25-EED21F75336B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting", "..\..\Analysis\UnitTesting\UnitTesting.csproj", "{1F261725-6318-4434-A1B1-6C70CE4CD324}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTesting.Tests", "..\..\Analysis\UnitTesting\Test\UnitTesting.Tests.csproj", "{44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -94,5 +98,13 @@ Global {0162E499-42D0-409B-AA25-EED21F75336B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.Build.0 = Release|Any CPU {0162E499-42D0-409B-AA25-EED21F75336B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.Build.0 = Release|Any CPU + {1F261725-6318-4434-A1B1-6C70CE4CD324}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.Build.0 = Release|Any CPU + {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181}.Release|Any CPU.ActiveCfg = Release|Any CPU EndGlobalSection EndGlobal diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin index 7559322692..1cfc29b3b3 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.addin @@ -1,7 +1,7 @@ - @@ -12,15 +12,16 @@ + + extensions=".py" + name="Python" + resource="ICSharpCode.PythonBinding.Resources.Python.xshd"/> @@ -30,19 +31,19 @@ + insertbefore="Resources" + insertafter="Icons" + name="${res:ICSharpCode.PythonBinding.PythonFiles} (*.py)" + extensions="*.py"/> - + + insertbefore="AllFiles" + name="${res:ICSharpCode.PythonBinding.PythonProjectFiles} (*.pyproj)" + class="ICSharpCode.SharpDevelop.Project.LoadProject" + extensions="*.pyproj"/> @@ -54,27 +55,27 @@ + insertafter="Search" + insertbefore="Tools" + label="&Python" + type="Menu"> + icon="Icons.16x16.RunProgramIcon" + class="ICSharpCode.PythonBinding.RunDebugPythonCommand" + label="${res:XML.MainMenu.RunMenu.Run}" + shortcut="Control|Shift|R"/> + icon="Icons.16x16.Debug.StartWithoutDebugging" + class="ICSharpCode.PythonBinding.RunPythonCommand" + label="${res:XML.MainMenu.DebugMenu.RunWithoutDebug}" + shortcut="Control|Shift|W"/> + icon="Icons.16x16.StopProcess" + class="ICSharpCode.SharpDevelop.Project.Commands.StopDebuggingCommand" + label="${res:XML.MainMenu.DebugMenu.Stop}"/> @@ -83,22 +84,22 @@ + supportedextensions=".py" + projectfileextension=".pyproj" + class="ICSharpCode.PythonBinding.PythonParser"/> + guid="{FD48973F-F585-4F70-812B-4D0503B36CE9}" + supportedextensions=".py" + projectfileextension=".pyproj" + class="ICSharpCode.PythonBinding.PythonProjectBinding" /> - + @@ -115,33 +116,33 @@ + label="Python" + class="ICSharpCode.PythonBinding.PythonOptionsPanel"/> + label="${res:Dialog.ProjectOptions.ApplicationSettings}" + class="ICSharpCode.PythonBinding.ApplicationSettingsPanel"/> + label="${res:Dialog.ProjectOptions.BuildEvents}" + class="ICSharpCode.SharpDevelop.Gui.OptionPanels.BuildEvents"/> + label="${res:Dialog.ProjectOptions.BuildOptions}" + class="ICSharpCode.PythonBinding.CompilingOptionsPanel"/> + label="${res:Dialog.ProjectOptions.DebugOptions}" + class="ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/> + type="Secondary" + fileNamePattern="\.py$" + languagePattern="^Python$" + class="ICSharpCode.PythonBinding.PythonFormsDesignerDisplayBinding" /> @@ -151,43 +152,49 @@ + insertafter="CSharp" + insertbefore="VBNet" + label="Python" + class="ICSharpCode.PythonBinding.ConvertToPythonMenuCommand"/> - - - + + + - - + + - - - - - - - + + + + + + + + + + + diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj index 03ac606f0d..7f35aa139f 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj @@ -74,11 +74,15 @@ + + + + @@ -89,11 +93,18 @@ + + + + + + + @@ -178,9 +189,16 @@ Always + + Always + + + Always + + @@ -208,6 +226,11 @@ ICSharpCode.SharpDevelop.Dom False + + {1F261725-6318-4434-A1B1-6C70CE4CD324} + UnitTesting + False + {7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} FormsDesigner diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm index f0194f88e2..fe281e6870 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Resources/PythonOptionsPanel.xfrm @@ -11,6 +11,20 @@ + + + + + + + + + + + + + + diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs index d4df5988ff..fd597347ab 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/AddInOptions.cs @@ -29,6 +29,7 @@ namespace ICSharpCode.PythonBinding #region Property names public static readonly string PythonFileNameProperty = "PythonFileName"; + public static readonly string PythonLibraryPathProperty = "PythonLibraryPath"; #endregion Properties properties; @@ -47,13 +48,20 @@ namespace ICSharpCode.PythonBinding this.properties = properties; } + public string PythonLibraryPath { + get { return properties.Get(PythonLibraryPathProperty, String.Empty); } + set { properties.Set(PythonLibraryPathProperty, value); } + } + + public bool HasPythonLibraryPath { + get { return !String.IsNullOrEmpty(PythonLibraryPath); } + } + /// /// Gets or sets the python console filename. /// public string PythonFileName { - get { - return properties.Get(PythonFileNameProperty, GetDefaultPythonFileName()); - } + get { return properties.Get(PythonFileNameProperty, GetDefaultPythonFileName()); } set { if (String.IsNullOrEmpty(value)) { properties.Set(PythonFileNameProperty, GetDefaultPythonFileName()); @@ -63,23 +71,19 @@ namespace ICSharpCode.PythonBinding } } - /// - /// Gets the path to the specified addin. - /// - /// The addin name: "${addin:ICSharpCode.PythonBinding}" - protected virtual string GetAddInPath(string addIn) - { - return StringParser.Parse(addIn); - } - /// /// Returns the full path to ipyw.exe which is installed in the /// Python addin folder. /// string GetDefaultPythonFileName() { - string path = GetAddInPath("${addinpath:ICSharpCode.PythonBinding}"); + string path = GetPythonBindingAddInPath(); return Path.Combine(path, DefaultPythonFileName); } + + string GetPythonBindingAddInPath() + { + return StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}"); + } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CreateTextWriterInfo.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CreateTextWriterInfo.cs new file mode 100644 index 0000000000..264fe024d5 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/CreateTextWriterInfo.cs @@ -0,0 +1,65 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; + +namespace ICSharpCode.PythonBinding +{ + public class CreateTextWriterInfo + { + string fileName; + Encoding encoding; + bool append; + + public CreateTextWriterInfo(string fileName, Encoding encoding, bool append) + { + this.fileName = fileName; + this.encoding = encoding; + this.append = append; + } + + public string FileName { + get { return fileName; } + } + + public Encoding Encoding { + get { return encoding; } + } + + public bool Append { + get { return append; } + } + + public override bool Equals(object obj) + { + CreateTextWriterInfo rhs = obj as CreateTextWriterInfo; + if (rhs != null) { + return Equals(rhs); + } + return false; + } + + bool Equals(CreateTextWriterInfo rhs) + { + return (fileName == rhs.fileName) && + (encoding == rhs.encoding) && + (append == rhs.append); + } + + public override int GetHashCode() + { + return base.GetHashCode(); + } + + public TextWriter CreateTextWriter() + { + return new StreamWriter(fileName, append, encoding); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs new file mode 100644 index 0000000000..822fa1adc3 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/IPythonFileService.cs @@ -0,0 +1,20 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; + +namespace ICSharpCode.PythonBinding +{ + public interface IPythonFileService + { + string GetTempFileName(); + TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo); + void DeleteFile(string fileName); + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs index 3c276ddd91..f3dbe7d692 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonAstWalker.cs @@ -23,18 +23,30 @@ namespace ICSharpCode.PythonBinding public class PythonAstWalker : PythonWalker { DefaultCompilationUnit compilationUnit; - DefaultClass currentClass; - DefaultClass globalClass; - string currentNamespace; + IClass currentClass; + IClass globalClass; /// /// All classes in a file take the namespace of the filename. /// public PythonAstWalker(IProjectContent projectContent, string fileName) + { + CreateCompilationUnit(projectContent, fileName); + } + + void CreateCompilationUnit(IProjectContent projectContent, string fileName) { compilationUnit = new DefaultCompilationUnit(projectContent); compilationUnit.FileName = fileName; - currentNamespace = Path.GetFileNameWithoutExtension(fileName); + + CreateUsingScopeForCompilationUnit(fileName); + } + + void CreateUsingScopeForCompilationUnit(string fileName) + { + DefaultUsingScope usingScope = new DefaultUsingScope(); + usingScope.NamespaceName = Path.GetFileNameWithoutExtension(fileName); + compilationUnit.UsingScope = usingScope; } /// @@ -62,7 +74,7 @@ namespace ICSharpCode.PythonBinding c.Region = GetRegion(node); c.BodyRegion = GetBodyRegion(node.Body, node.Header); AddBaseTypes(c, node.Bases); - + // Save the class. compilationUnit.Classes.Add(c); @@ -80,7 +92,7 @@ namespace ICSharpCode.PythonBinding public override bool Walk(FunctionDefinition node) { if (node.Body == null) { - return true; + return false; } bool ignoreFirstMethodParameter = true; @@ -91,7 +103,7 @@ namespace ICSharpCode.PythonBinding c = globalClass; ignoreFirstMethodParameter = false; } - + // Create method. string methodName = node.Name; DomRegion bodyRegion = GetBodyRegion(node.Body, node.Header); @@ -107,7 +119,7 @@ namespace ICSharpCode.PythonBinding method.Parameters.Add(parameter); } c.Methods.Add(method); - return true; + return false; } /// @@ -120,7 +132,7 @@ namespace ICSharpCode.PythonBinding compilationUnit.UsingScope.Usings.Add(import); return false; } - + public override bool Walk(FromImportStatement node) { PythonFromImport import = new PythonFromImport(compilationUnit.ProjectContent, node); @@ -185,7 +197,12 @@ namespace ICSharpCode.PythonBinding /// void AddBaseType(IClass c, string name) { - c.BaseTypes.Add(new SearchClassReturnType(c.ProjectContent, c, 0, 0, name, 0)); + c.BaseTypes.Add(CreateSearchClassReturnType(c, name)); + } + + SearchClassReturnType CreateSearchClassReturnType(IClass c, string name) + { + return new SearchClassReturnType(c.ProjectContent, c, 0, 0, name, 0); } /// @@ -215,7 +232,7 @@ namespace ICSharpCode.PythonBinding /// string GetFullyQualifiedClassName(ClassDefinition classDef) { - return String.Concat(currentNamespace, ".", classDef.Name); + return String.Concat(compilationUnit.UsingScope.NamespaceName, ".", classDef.Name); } /// @@ -224,7 +241,7 @@ namespace ICSharpCode.PythonBinding void CreateGlobalClass() { if (globalClass == null) { - globalClass = new DefaultClass(compilationUnit, currentNamespace); + globalClass = new DefaultClass(compilationUnit, compilationUnit.UsingScope.NamespaceName); compilationUnit.Classes.Add(globalClass); } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs index 434394315b..3564feabfb 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsole.cs @@ -50,25 +50,15 @@ namespace ICSharpCode.PythonBinding //textArea.KeyEventHandler -= ProcessKeyPress; //textArea.DoProcessDialogKey -= ProcessDialogKey; } - + public TextWriter Output { - get { - Console.WriteLine("PythonConsole.Output get"); - return null; - } - set { - Console.WriteLine("PythonConsole.Output set"); - } + get { return null; } + set { } } public TextWriter ErrorOutput { - get { - Console.WriteLine("PythonConsole.ErrorOutput get"); - return null; - } - set { - Console.WriteLine("PythonConsole.ErrorOutput get"); - } + get { return null; } + set { } } /// @@ -90,8 +80,6 @@ namespace ICSharpCode.PythonBinding /// public string ReadLine(int autoIndentSize) { - Console.WriteLine("PythonConsole.ReadLine(): autoIndentSize: " + autoIndentSize); - string indent = String.Empty; if (autoIndentSize > 0) { indent = String.Empty.PadLeft(autoIndentSize); @@ -100,7 +88,6 @@ namespace ICSharpCode.PythonBinding string line = ReadLineFromTextEditor(); if (line != null) { - Console.WriteLine("ReadLine: " + indent + line); return indent + line; } return null; @@ -111,10 +98,7 @@ namespace ICSharpCode.PythonBinding /// public void Write(string text, Style style) { - Console.WriteLine("PythonConsole.Write(text, style): " + text); - textEditor.Write(text); - if (style == Style.Prompt) { promptLength = text.Length; textEditor.MakeCurrentContentReadOnly(); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs new file mode 100644 index 0000000000..eff8b57007 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonConsoleApplication.cs @@ -0,0 +1,109 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.Text; + +namespace ICSharpCode.PythonBinding +{ + public class PythonConsoleApplication + { + string fileName = String.Empty; + StringBuilder arguments; + bool debug; + string pythonScriptFileName = String.Empty; + string pythonScriptCommandLineArguments = String.Empty; + string workingDirectory = String.Empty; + + public PythonConsoleApplication(AddInOptions options) + : this(options.PythonFileName) + { + } + + public PythonConsoleApplication(string fileName) + { + this.fileName = fileName; + } + + public string FileName { + get { return fileName; } + } + + public bool Debug { + get { return debug; } + set { debug = value; } + } + + public string PythonScriptFileName { + get { return pythonScriptFileName; } + set { pythonScriptFileName = value; } + } + + public string PythonScriptCommandLineArguments { + get { return pythonScriptCommandLineArguments; } + set { pythonScriptCommandLineArguments = value; } + } + + public string WorkingDirectory { + get { return workingDirectory; } + set { workingDirectory = value; } + } + + public ProcessStartInfo GetProcessStartInfo() + { + ProcessStartInfo processStartInfo = new ProcessStartInfo(); + processStartInfo.FileName = fileName; + processStartInfo.Arguments = GetArguments(); + processStartInfo.WorkingDirectory = workingDirectory; + return processStartInfo; + } + + public string GetArguments() + { + arguments = new StringBuilder(); + + AppendBooleanOptionIfTrue("-X:Debug", debug); + AppendQuotedStringIfNotEmpty(pythonScriptFileName); + AppendStringIfNotEmpty(pythonScriptCommandLineArguments); + + return arguments.ToString().TrimEnd(); + } + + void AppendBooleanOptionIfTrue(string option, bool flag) + { + if (flag) { + AppendOption(option); + } + } + + void AppendOption(string option) + { + arguments.Append(option + " "); + } + + void AppendQuotedStringIfNotEmpty(string option) + { + if (!String.IsNullOrEmpty(option)) { + AppendQuotedString(option); + } + } + + void AppendQuotedString(string option) + { + string quotedOption = String.Format("\"{0}\"", option); + AppendOption(quotedOption); + } + + void AppendStringIfNotEmpty(string option) + { + if (!String.IsNullOrEmpty(option)) { + AppendOption(option); + } + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs new file mode 100644 index 0000000000..afca45eb89 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonFileService.cs @@ -0,0 +1,31 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; + +namespace ICSharpCode.PythonBinding +{ + public class PythonFileService : IPythonFileService + { + public string GetTempFileName() + { + return Path.GetTempFileName(); + } + + public TextWriter CreateTextWriter(CreateTextWriterInfo createTextWriterInfo) + { + return createTextWriterInfo.CreateTextWriter(); + } + + public void DeleteFile(string fileName) + { + File.Delete(fileName); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs index 21f899a422..01c979f66d 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonOptionsPanel.cs @@ -5,11 +5,11 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.Gui.OptionPanels; using System; using System.Drawing; using System.Windows.Forms; using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Gui.OptionPanels; using ICSharpCode.SharpDevelop.Project; namespace ICSharpCode.PythonBinding @@ -21,6 +21,7 @@ namespace ICSharpCode.PythonBinding { AddInOptions options; TextBox pythonFileNameTextBox; + TextBox pythonLibraryPathTextBox; public PythonOptionsPanel() : this(new AddInOptions()) { @@ -38,12 +39,16 @@ namespace ICSharpCode.PythonBinding pythonFileNameTextBox = (TextBox)ControlDictionary["pythonFileNameTextBox"]; pythonFileNameTextBox.Text = options.PythonFileName; + pythonLibraryPathTextBox = (TextBox)ControlDictionary["pythonLibraryPathTextBox"]; + pythonLibraryPathTextBox.Text = options.PythonLibraryPath; + ConnectBrowseButton("browseButton", "pythonFileNameTextBox", "${res:SharpDevelop.FileFilter.ExecutableFiles}|*.exe", TextBoxEditMode.EditRawProperty); } public override bool StorePanelContents() { options.PythonFileName = pythonFileNameTextBox.Text; + options.PythonLibraryPath = pythonLibraryPathTextBox.Text; return true; } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonStandardLibraryPath.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonStandardLibraryPath.cs new file mode 100644 index 0000000000..36da59f78a --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonStandardLibraryPath.cs @@ -0,0 +1,77 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using System.IO; +using System.Security; +using Microsoft.Win32; + +namespace ICSharpCode.PythonBinding +{ + public class PythonStandardLibraryPath + { + List directories = new List(); + string path = String.Empty; + + public PythonStandardLibraryPath(string path) + { + Path = path; + } + + public PythonStandardLibraryPath() + { + ReadPathFromRegistry(); + } + + void ReadPathFromRegistry() + { + try { + using (RegistryKey registryKey = GetPythonLibraryRegistryKey()) { + if (registryKey != null) { + Path = (string)registryKey.GetValue(String.Empty, String.Empty); + } + } + } catch (SecurityException) { + } catch (UnauthorizedAccessException) { + } catch (IOException) { + } + } + + RegistryKey GetPythonLibraryRegistryKey() + { + return Registry.LocalMachine.OpenSubKey(@"Software\Python\PythonCore\2.6\PythonPath"); + } + + public string[] Directories { + get { return directories.ToArray(); } + } + + public string Path { + get { return path; } + set { + path = value; + ReadDirectories(); + } + } + + void ReadDirectories() + { + directories.Clear(); + foreach (string item in path.Split(';')) { + string directory = item.Trim(); + if (!String.IsNullOrEmpty(directory)) { + directories.Add(directory); + } + } + } + + public bool HasPath { + get { return directories.Count > 0; } + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs new file mode 100644 index 0000000000..3e9e6b31f8 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestDebugger.cs @@ -0,0 +1,73 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.PythonBinding +{ + public class PythonTestDebugger : TestDebuggerBase + { + AddInOptions options; + IPythonFileService fileService; + PythonTestRunnerApplication testRunnerApplication; + PythonStandardLibraryPath pythonStandardLibraryPath; + + public PythonTestDebugger() + : this(new UnitTestDebuggerService(), + new UnitTestMessageService(), + new TestResultsMonitor(), + new AddInOptions(), + new PythonStandardLibraryPath(), + new PythonFileService()) + { + } + + public PythonTestDebugger(IUnitTestDebuggerService debuggerService, + IUnitTestMessageService messageService, + ITestResultsMonitor testResultsMonitor, + AddInOptions options, + PythonStandardLibraryPath pythonStandardLibraryPath, + IPythonFileService fileService) + : base(debuggerService, messageService, testResultsMonitor) + { + this.options = options; + this.pythonStandardLibraryPath = pythonStandardLibraryPath; + this.fileService = fileService; + } + + public override void Start(SelectedTests selectedTests) + { + CreateTestRunnerApplication(); + testRunnerApplication.CreateResponseFile(selectedTests); + base.Start(selectedTests); + } + + void CreateTestRunnerApplication() + { + testRunnerApplication = new PythonTestRunnerApplication(base.TestResultsMonitor.FileName, options, pythonStandardLibraryPath, fileService); + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + testRunnerApplication.Debug = true; + return testRunnerApplication.CreateProcessStartInfo(selectedTests); + } + + public override void Dispose() + { + testRunnerApplication.Dispose(); + base.Dispose(); + } + + protected override TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return new PythonTestResult(testResult); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestFramework.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestFramework.cs new file mode 100644 index 0000000000..57e520f5b1 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestFramework.cs @@ -0,0 +1,64 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.PythonBinding +{ + public class PythonTestFramework : ITestFramework + { + public bool IsTestMethod(IMember member) + { + if (member != null) { + return member.Name.StartsWith("test"); + } + return false; + } + + public bool IsTestClass(IClass c) + { + while (c != null) { + if (HasTestCaseBaseType(c)) { + return true; + } + c = c.BaseClass; + } + return false; + } + + bool HasTestCaseBaseType(IClass c) + { + if (c.BaseTypes.Count > 0) { + string baseTypeName = c.BaseTypes[0].FullyQualifiedName; + return (baseTypeName == "unittest.TestCase") || (baseTypeName == "unittest2.TestCase"); + } + return false; + } + + public bool IsTestProject(IProject project) + { + return project is PythonProject; + } + + public ITestRunner CreateTestRunner() + { + return new PythonTestRunner(); + } + + public ITestRunner CreateTestDebugger() + { + return new PythonTestDebugger(); + } + + public bool IsBuildNeededBeforeTestRun { + get { return false; } + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestResult.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestResult.cs new file mode 100644 index 0000000000..62fc443a6b --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestResult.cs @@ -0,0 +1,66 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using System.Text.RegularExpressions; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.PythonBinding +{ + public class PythonTestResult : TestResult + { + public PythonTestResult(TestResult testResult) + : base(testResult.Name) + { + ResultType = testResult.ResultType; + Message = testResult.Message; + StackTrace = testResult.StackTrace; + } + + protected override void OnStackTraceChanged() + { + if (String.IsNullOrEmpty(StackTrace)) { + ResetStackTraceFilePosition(); + } else { + GetFilePositionFromStackTrace(); + } + } + + void ResetStackTraceFilePosition() + { + StackTraceFilePosition = FilePosition.Empty; + } + + /// + /// Stack trace: + /// Traceback (most recent call last): + /// File "d:\temp\test\PyTests\Tests\MyClassTest.py", line 19, in testRaiseException + /// raise 'abc' + /// + void GetFilePositionFromStackTrace() + { + Match match = Regex.Match(StackTrace, "\\sFile\\s\"(.*?)\",\\sline\\s(\\d+),", RegexOptions.Multiline); + if (match.Success) { + try { + SetStackTraceFilePosition(match.Groups); + } catch (OverflowException) { + // Ignore. + } + } + } + + void SetStackTraceFilePosition(GroupCollection groups) + { + string fileName = groups[1].Value; + int line = Convert.ToInt32(groups[2].Value); + int column = 1; + + StackTraceFilePosition = new FilePosition(fileName, line, column); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs new file mode 100644 index 0000000000..461a203135 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunner.cs @@ -0,0 +1,73 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.PythonBinding +{ + public class PythonTestRunner : TestProcessRunnerBase + { + AddInOptions options; + PythonStandardLibraryPath pythonStandardLibraryPath; + IPythonFileService fileService; + PythonTestRunnerApplication testRunnerApplication; + + public PythonTestRunner() + : this(new UnitTestProcessRunner(), + new TestResultsMonitor(), + new AddInOptions(), + new PythonStandardLibraryPath(), + new PythonFileService()) + { + } + + public PythonTestRunner(IUnitTestProcessRunner processRunner, + ITestResultsMonitor testResultsMonitor, + AddInOptions options, + PythonStandardLibraryPath pythonStandardLibraryPath, + IPythonFileService fileService) + : base(processRunner, testResultsMonitor) + { + this.options = options; + this.pythonStandardLibraryPath = pythonStandardLibraryPath; + this.fileService = fileService; + } + + public override void Start(SelectedTests selectedTests) + { + CreateTestRunnerApplication(); + testRunnerApplication.CreateResponseFile(selectedTests); + base.Start(selectedTests); + } + + void CreateTestRunnerApplication() + { + testRunnerApplication = new PythonTestRunnerApplication(base.TestResultsMonitor.FileName, options, pythonStandardLibraryPath, fileService); + } + + protected override ProcessStartInfo GetProcessStartInfo(SelectedTests selectedTests) + { + return testRunnerApplication.CreateProcessStartInfo(selectedTests); + } + + public override void Dispose() + { + testRunnerApplication.Dispose(); + base.Dispose(); + } + + protected override TestResult CreateTestResultForTestFramework(TestResult testResult) + { + return new PythonTestResult(testResult); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerApplication.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerApplication.cs new file mode 100644 index 0000000000..5414ecf030 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerApplication.cs @@ -0,0 +1,109 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using ICSharpCode.Core; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.PythonBinding +{ + public class PythonTestRunnerApplication + { + string testResultsFileName = String.Empty; + AddInOptions options; + PythonStandardLibraryPath pythonStandardLibraryPath; + PythonTestRunnerResponseFile responseFile; + IPythonFileService fileService; + CreateTextWriterInfo textWriterInfo; + PythonConsoleApplication consoleApplication; + + public PythonTestRunnerApplication(string testResultsFileName, + AddInOptions options, + PythonStandardLibraryPath pythonStandardLibraryPath, + IPythonFileService fileService) + { + this.testResultsFileName = testResultsFileName; + this.options = options; + this.pythonStandardLibraryPath = pythonStandardLibraryPath; + this.fileService = fileService; + consoleApplication = new PythonConsoleApplication(options); + } + + public bool Debug { + get { return consoleApplication.Debug; } + set { consoleApplication.Debug = value; } + } + + public void CreateResponseFile(SelectedTests selectedTests) + { + CreateResponseFile(); + using (responseFile) { + WritePythonSystemPaths(); + WriteTestsResultsFileName(); + WriteTests(selectedTests); + } + } + + void CreateResponseFile() + { + TextWriter writer = CreateTextWriter(); + responseFile = new PythonTestRunnerResponseFile(writer); + } + + TextWriter CreateTextWriter() + { + string fileName = fileService.GetTempFileName(); + textWriterInfo = new CreateTextWriterInfo(fileName, Encoding.UTF8, false); + return fileService.CreateTextWriter(textWriterInfo); + } + + void WritePythonSystemPaths() + { + if (options.HasPythonLibraryPath) { + responseFile.WritePath(options.PythonLibraryPath); + } else if (pythonStandardLibraryPath.HasPath) { + responseFile.WritePaths(pythonStandardLibraryPath.Directories); + } + } + + void WriteTestsResultsFileName() + { + responseFile.WriteResultsFileName(testResultsFileName); + } + + void WriteTests(SelectedTests selectedTests) + { + responseFile.WriteTests(selectedTests); + } + + public ProcessStartInfo CreateProcessStartInfo(SelectedTests selectedTests) + { + consoleApplication.PythonScriptFileName = GetSharpDevelopTestPythonScriptFileName(); + consoleApplication.PythonScriptCommandLineArguments = GetResponseFileNameCommandLineArgument(); + consoleApplication.WorkingDirectory = selectedTests.Project.Directory; + return consoleApplication.GetProcessStartInfo(); + } + + string GetSharpDevelopTestPythonScriptFileName() + { + return StringParser.Parse(@"${addinpath:ICSharpCode.PythonBinding}\TestRunner\sdtest.py"); + } + + string GetResponseFileNameCommandLineArgument() + { + return String.Format("\"@{0}\"", textWriterInfo.FileName); + } + + public void Dispose() + { + fileService.DeleteFile(textWriterInfo.FileName); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerResponseFile.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerResponseFile.cs new file mode 100644 index 0000000000..9e526a0d00 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonTestRunnerResponseFile.cs @@ -0,0 +1,122 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.ObjectModel; +using System.IO; +using System.Text; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; + +namespace ICSharpCode.PythonBinding +{ + public class PythonTestRunnerResponseFile : IDisposable + { + TextWriter writer; + + public PythonTestRunnerResponseFile(string fileName) + : this(new StreamWriter(fileName, false, Encoding.UTF8)) + { + } + + public PythonTestRunnerResponseFile(TextWriter writer) + { + this.writer = writer; + } + + public void WriteTest(string testName) + { + writer.WriteLine(testName); + } + + public void WritePaths(string[] paths) + { + foreach (string path in paths) { + WritePath(path); + } + } + + public void WritePathIfNotEmpty(string path) + { + if (!String.IsNullOrEmpty(path)) { + WritePath(path); + } + } + + public void WritePath(string path) + { + WriteQuotedArgument("p", path); + } + + void WriteQuotedArgument(string option, string value) + { + writer.WriteLine("/{0}:\"{1}\"", option, value); + } + + public void WriteResultsFileName(string fileName) + { + WriteQuotedArgument("r", fileName); + } + + public void Dispose() + { + writer.Dispose(); + } + + public void WriteTests(SelectedTests selectedTests) + { + WritePathsForReferencedProjects(selectedTests.Project); + + if (selectedTests.Method != null) { + WriteTest(selectedTests.Method.FullyQualifiedName); + } else if (selectedTests.Class != null) { + WriteTest(selectedTests.Class.FullyQualifiedName); + } else if (!String.IsNullOrEmpty(selectedTests.NamespaceFilter)) { + WriteTest(selectedTests.NamespaceFilter); + } else { + WriteProjectTests(selectedTests.Project); + } + + } + + void WriteProjectTests(IProject project) + { + if (project != null) { + WriteProjectFileItems(project.Items); + } + } + + void WritePathsForReferencedProjects(IProject project) + { + if (project != null) { + foreach (ProjectItem item in project.Items) { + ProjectReferenceProjectItem projectRef = item as ProjectReferenceProjectItem; + if (projectRef != null) { + string directory = Path.GetDirectoryName(projectRef.FileName); + WritePathIfNotEmpty(directory); + } + } + } + } + + void WriteProjectFileItems(ReadOnlyCollection items) + { + foreach (ProjectItem item in items) { + FileProjectItem fileItem = item as FileProjectItem; + if (fileItem != null) { + WriteFileNameWithoutExtension(fileItem.FileName); + } + } + } + + void WriteFileNameWithoutExtension(string fileName) + { + string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName); + WriteTest(fileNameWithoutExtension); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs index b962b15407..2f53fced95 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/RunPythonCommand.cs @@ -23,7 +23,7 @@ namespace ICSharpCode.PythonBinding IDebugger debugger; AddInOptions options; IWorkbench workbench; - bool debug; + PythonConsoleApplication ipy; public RunPythonCommand() : this(WorkbenchSingleton.Workbench, new AddInOptions(), DebuggerService.CurrentDebugger) @@ -35,40 +35,28 @@ namespace ICSharpCode.PythonBinding this.workbench = workbench; this.debugger = debugger; this.options = options; + ipy = new PythonConsoleApplication(options); } public bool Debug { - get { return debug; } - set { debug = value; } + get { return ipy.Debug; } + set { ipy.Debug = value; } } public override void Run() { - if (debug) { - debugger.Start(CreateProcessStartInfo()); + ProcessStartInfo processStartInfo = GetProcessStartInfo(); + if (Debug) { + debugger.Start(processStartInfo); } else { - debugger.StartWithoutDebugging(CreateProcessStartInfo()); + debugger.StartWithoutDebugging(processStartInfo); } } - ProcessStartInfo CreateProcessStartInfo() - { - ProcessStartInfo info = new ProcessStartInfo(); - info.FileName = options.PythonFileName; - info.Arguments = GetArguments(); - - return info; - } - - string GetArguments() + ProcessStartInfo GetProcessStartInfo() { - // Get the python script filename. - string pythonScriptFileName = "\"" + workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName + "\""; - - if (Debug) { - return "-D " + pythonScriptFileName; - } - return pythonScriptFileName; + ipy.PythonScriptFileName = workbench.ActiveWorkbenchWindow.ActiveViewContent.PrimaryFileName; + return ipy.GetProcessStartInfo(); } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtest.py b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtest.py new file mode 100644 index 0000000000..3510f6fcfa --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtest.py @@ -0,0 +1,95 @@ + +import sys +import System.IO + +class SharpDevelopTestProgram: + + def __init__(self): + self._sysPaths = [] + self._testNames = [] + + def run(self): + if self._validateCommandLineArgs(): + self._runTests() + return + + print 'Usage: sdunittest.py test-names-file sys-paths-file test-results-file' + print 'Usage: sdunittest.py @response-file' + print '' + print 'Example response file content: ' + print '/p:"sys/path/1"' + print '/p:"sys/path/2"' + print '/r:"path/to/results-file"' + print 'test-name1' + print 'test-name2' + print 'test-name3' + + def _validateCommandLineArgs(self): + if len(sys.argv) == 4: + self._testNamesFile = sys.argv[1] + self._sysPathFile = sys.argv[2] + self._testResultsFile = sys.argv[3] + self._responseFile = '' + return True + if len(sys.argv) == 2: + return self._getResponseFileName(sys.argv[1]) + return False + + def _getResponseFileName(self, fileName): + if len(fileName) > 0: + if fileName[0] == '@': + self._responseFile = fileName[1:] + return True + return False + + def _runTests(self): + if len(self._responseFile) > 0: + self._readResponseFile() + else: + self._readSysPathsFromFile() + self._readTestNames() + + self._addSysPaths() + + import unittest + import sdtestrunner + + suite = unittest.TestLoader().loadTestsFromNames(self._testNames) + sdtestrunner.SharpDevelopTestRunner(resultsFileName=self._testResultsFile, verbosity=2).run(suite) + + def _readResponseFile(self): + for line in self._readLinesFromFile(self._responseFile): + self._readResponseFileArgument(line) + + def _readResponseFileArgument(self, line): + if line.startswith('/r:'): + line = self._removeQuotes(line[3:]) + self._testResultsFile = line + elif line.startswith('/p:'): + line = self._removeQuotes(line[3:]) + self._sysPaths.append(line) + else: + self._testNames.append(line) + + def _removeQuotes(self, line): + return line.strip('\"') + + def _readLinesFromFile(self, fileName): + #f = codecs.open(fileName, 'rb', 'utf-8') + #return f.readall().splitlines() + return System.IO.File.ReadAllLines(fileName) + + def _readTestNames(self): + self._testNames = self._readLinesFromFile(self._testNamesFile) + + def _readSysPathsFromFile(self): + self._sysPaths = self._readLinesFromFile(self._sysPathFile) + + def _addSysPaths(self): + for path in self._sysPaths: + sys.path.append(path) + + +if __name__ == '__main__': + program = SharpDevelopTestProgram() + program.run() diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtestrunner.py b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtestrunner.py new file mode 100644 index 0000000000..9fa36d46c3 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/TestRunner/sdtestrunner.py @@ -0,0 +1,106 @@ + +import codecs +import sys +import time +from unittest import TestResult +from unittest import TextTestRunner +from unittest import _TextTestResult +from unittest import _WritelnDecorator + +class _SharpDevelopTestResultWriter: + def __init__(self, resultsFileName): + self.stream = codecs.open(resultsFileName, "w+", "utf-8-sig") + + def _writeln(self, arg): + self.stream.write(arg) + self.stream.write('\r\n') + + def _writeTestName(self, test): + self._writeln("Name: " + test.id()) + + def _writeTestResult(self, result): + self._writeln("Result: " + result) + + def _writeTestSuccess(self): + self._writeTestResult("Success") + + def _writeTestFailure(self, test, err, testResult): + self._writeTestResult("Failure") + + exctype, value, tb = err + if value != None: + message = self._prefixLinesWithSpaceChar(str(value)) + self._writeln("Message: " + message) + + excInfoString = testResult._exc_info_to_string(err, test) + excInfoString = self._prefixLinesWithSpaceChar(excInfoString) + self._writeln("StackTrace: " + excInfoString) + + def _prefixLinesWithSpaceChar(self, text): + lines = [] + originalLines = text.splitlines() + if len(originalLines) == 0: + return text + + lines.append(originalLines[0] + '\r\n') + + for line in originalLines[1:]: + lines.append(' ' + line + '\r\n') + return ''.join(lines).rstrip() + + def addSuccess(self, test): + self._writeTestName(test) + self._writeTestSuccess() + + def addError(self, test, err, testResult): + self._writeTestName(test) + self._writeTestFailure(test, err, testResult) + + def addFailure(self, test, err, testResult): + self._writeTestName(test) + self._writeTestFailure(test, err, testResult) + +class _SharpDevelopNullTestResultWriter: + def __init__(self): + pass + + def addSuccess(self, test): + pass + + def addError(self, test, err, testResult): + pass + + def addFailure(self, test, err, testResult): + pass + + +class _SharpDevelopTestResult(_TextTestResult): + def __init__(self, stream, descriptions, verbosity, resultWriter): + _TextTestResult.__init__(self, stream, descriptions, verbosity) + self.resultWriter = resultWriter + + def addSuccess(self, test): + self.resultWriter.addSuccess(test) + _TextTestResult.addSuccess(self, test) + + def addError(self, test, err): + self.resultWriter.addError(test, err, self) + _TextTestResult.addError(self, test, err) + + def addFailure(self, test, err): + self.resultWriter.addFailure(test, err, self) + _TextTestResult.addFailure(self, test, err) + + +class SharpDevelopTestRunner(TextTestRunner): + def __init__(self, stream=sys.stderr, resultsFileName=None, descriptions=1, verbosity=1): + self.stream = _WritelnDecorator(stream) + self.descriptions = descriptions + self.verbosity = verbosity + if resultsFileName is None: + self.resultWriter = _SharpDevelopNullTestResultWriter() + else: + self.resultWriter = _SharpDevelopTestResultWriter(resultsFileName) + + def _makeResult(self): + return _SharpDevelopTestResult(self.stream, self.descriptions, self.verbosity, self.resultWriter) diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInOptionsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInOptionsTestFixture.cs deleted file mode 100644 index 7306089ba7..0000000000 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInOptionsTestFixture.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.IO; -using ICSharpCode.Core; -using ICSharpCode.PythonBinding; -using NUnit.Framework; -using PythonBinding.Tests.Utils; - -namespace PythonBinding.Tests -{ - /// - /// Tests the AddInOptions class. - /// - [TestFixture] - public class AddInOptionsTestFixture - { - [Test] - public void DefaultPythonConsoleFileName() - { - Properties p = new Properties(); - DerivedAddInOptions options = new DerivedAddInOptions(p); - options.AddInPath = @"C:\Projects\SD\AddIns\Python"; - - string expectedFileName = Path.Combine(options.AddInPath, "ipy.exe"); - Assert.AreEqual(expectedFileName, options.PythonFileName); - Assert.AreEqual("${addinpath:ICSharpCode.PythonBinding}", options.AddInPathRequested); - } - - [Test] - public void SetPythonConsoleFileNameToNull() - { - Properties p = new Properties(); - DerivedAddInOptions options = new DerivedAddInOptions(p); - options.AddInPath = @"C:\Projects\SD\AddIns\Python"; - options.PythonFileName = null; - - string expectedFileName = Path.Combine(options.AddInPath, "ipy.exe"); - Assert.AreEqual(expectedFileName, options.PythonFileName); - } - - [Test] - public void SetPythonConsoleFileNameToEmptyString() - { - Properties p = new Properties(); - DerivedAddInOptions options = new DerivedAddInOptions(p); - options.AddInPath = @"C:\Projects\SD\AddIns\Python"; - options.PythonFileName = String.Empty; - - string expectedFileName = Path.Combine(options.AddInPath, "ipy.exe"); - Assert.AreEqual(expectedFileName, options.PythonFileName); - } - - [Test] - public void SetPythonConsoleFileName() - { - Properties p = new Properties(); - AddInOptions options = new AddInOptions(p); - string fileName = @"C:\IronPython\ipy.exe"; - options.PythonFileName = fileName; - - Assert.AreEqual(fileName, options.PythonFileName); - Assert.AreEqual(fileName, p["PythonFileName"]); - } - } -} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CodeCompletionBindingFromImportCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/CodeCompletionBindingFromImportCompletionTestFixture.cs deleted file mode 100644 index 8d560b5fb5..0000000000 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CodeCompletionBindingFromImportCompletionTestFixture.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.Core; -using ICSharpCode.PythonBinding; -using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; -using ICSharpCode.SharpDevelop.Dom; -using NUnit.Framework; -using PythonBinding.Tests.Utils; - -namespace PythonBinding.Tests -{ - /// - /// Tests that the From keyword is correctly identified as a - /// importable code completion keyword. - /// - [TestFixture] - public class FromImportCompletionTestFixture - { - DerivedPythonCodeCompletionBinding codeCompletionBinding; - bool handlesImportKeyword; - SharpDevelopTextAreaControl textAreaControl; - - [TestFixtureSetUp] - public void SetUpFixture() - { - if (!PropertyService.Initialized) { - PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); - } - textAreaControl = new SharpDevelopTextAreaControl(); - codeCompletionBinding = new DerivedPythonCodeCompletionBinding(); - handlesImportKeyword = codeCompletionBinding.HandleKeyword(textAreaControl, "from"); - } - - [Test] - public void HandlesImportKeyWord() - { - Assert.IsTrue(handlesImportKeyword); - } - - [Test] - public void ExpressionContextIsImportable() - { - Assert.AreEqual(ExpressionContext.Importable, codeCompletionBinding.ExpressionContext); - } - } -} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs index e50567742b..49d26d4e59 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/CodeCompletionBindingImportCompletionTestFixture.cs @@ -8,12 +8,12 @@ using System; using ICSharpCode.Core; using ICSharpCode.PythonBinding; -using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Editor.AvalonEdit; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Completion { /// /// Tests the code completion after an "import" statement. @@ -48,7 +48,7 @@ namespace PythonBinding.Tests Assert.IsFalse(codeCompletionBinding.HandleKeyword(textEditor, "Unknown")); } - [Test] + [Test] public void HandlesUppercaseImportKeyword() { Assert.IsTrue(codeCompletionBinding.HandleKeyword(textEditor, "IMPORT")); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs index 258b9df69a..fb803ad45f 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Completion/NamespaceContentsAddedToCtrlSpaceTestFixture.cs @@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { @@ -25,14 +26,14 @@ namespace PythonBinding.Tests.Resolver { List results; PythonResolver resolver; - MockProjectContent mockProjectContent; + PythonBinding.Tests.Utils.MockProjectContent mockProjectContent; MockClass myTestClass; [TestFixtureSetUp] public void SetUpFixture() { resolver = new PythonResolver(); - mockProjectContent = new MockProjectContent(); + mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent(); mockProjectContent.NamespacesToAdd.Add("Test"); myTestClass = new MockClass(mockProjectContent, "MyTestClass"); List namespaceItems = new List(); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInFileTestFixture.cs similarity index 93% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInFileTestFixture.cs index 6548db301f..34bd86cf24 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AddInFileTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInFileTestFixture.cs @@ -15,7 +15,7 @@ using ICSharpCode.TextEditor.Document; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Configuration { /// /// Basic PythonBinding.addin file tests. @@ -50,6 +50,10 @@ namespace PythonBinding.Tests Codon convertCSharpProjectCodon; Codon convertVBNetProjectCodon; Codon formattingStrategyCodon; + Runtime sharpdevelopRuntime; + Runtime ironpythonModulesRuntime; + Runtime unitTestingRuntime; + Codon testFrameworkCodon; [TestFixtureSetUp] public void SetupFixture() @@ -83,13 +87,20 @@ namespace PythonBinding.Tests convertCSharpProjectCodon = GetCodon("/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert", "CSharpProjectToPythonProjectConverter"); convertVBNetProjectCodon = GetCodon("/SharpDevelop/Pads/ProjectBrowser/ContextMenu/ProjectActions/Convert", "VBNetProjectToPythonProjectConverter"); formattingStrategyCodon = GetCodon("/AddIns/DefaultTextEditor/Formatter/Python", "PythonFormatter"); - + testFrameworkCodon = GetCodon("/SharpDevelop/UnitTesting/TestFrameworks", "pyunit"); + // Get the PythonBinding runtime. foreach (Runtime runtime in addin.Runtimes) { if (runtime.Assembly == "PythonBinding.dll") { - pythonBindingRuntime = runtime; + pythonBindingRuntime = runtime; } else if (runtime.Assembly == "$ICSharpCode.FormsDesigner/FormsDesigner.dll") { formsDesignerRuntime = runtime; + } else if (runtime.Assembly == "IronPython.Modules.dll") { + ironpythonModulesRuntime = runtime; + } else if (runtime.Assembly == ":ICSharpCode.SharpDevelop") { + sharpdevelopRuntime = runtime; + } else if (runtime.Assembly == "$ICSharpCode.UnitTesting/UnitTesting.dll") { + unitTestingRuntime = runtime; } } @@ -128,11 +139,29 @@ namespace PythonBinding.Tests } [Test] - public void RuntimeExists() + public void PythonBindingRuntimeExists() { Assert.IsNotNull(pythonBindingRuntime); } + [Test] + public void ICSharpCodeSharpDevelopRuntimeExists() + { + Assert.IsNotNull(sharpdevelopRuntime); + } + + [Test] + public void IronPythonModulesRuntimeExists() + { + Assert.IsNotNull(ironpythonModulesRuntime); + } + + [Test] + public void UnitTestingRuntimeExists() + { + Assert.IsNotNull(unitTestingRuntime); + } + [Test] public void FileFilterExists() { @@ -725,22 +754,40 @@ namespace PythonBinding.Tests { Assert.AreEqual(1, pythonWithoutDebuggerRunMenuItemCodon.Conditions.Length); } - + [Test] public void PythonDebugRunConditionIsSameAsPythonRunCondition() { Assert.AreEqual(pythonWithoutDebuggerRunMenuItemCodon.Conditions[0], pythonRunMenuItemCodon.Conditions[0]); } - + [Test] public void PythonFormatterClass() { Assert.AreEqual("ICSharpCode.PythonBinding.PythonFormattingStrategy", formattingStrategyCodon["class"]); } + [Test] + public void TestFrameworkCodonExists() + { + Assert.IsNotNull(testFrameworkCodon); + } + + [Test] + public void TestFrameworkClassIsPythonTestFrameworks() + { + Assert.AreEqual("ICSharpCode.PythonBinding.PythonTestFramework", testFrameworkCodon["class"]); + } + + [Test] + public void TestFrameworkSupportedProjectsIsPythonProject() + { + Assert.AreEqual(".pyproj", testFrameworkCodon["supportedProjects"]); + } + Codon GetCodon(string name, string extensionPath) { return AddInHelper.GetCodon(addin, name, extensionPath); - } + } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInOptionsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInOptionsTestFixture.cs new file mode 100644 index 0000000000..3ebb9d18e3 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Configuration/AddInOptionsTestFixture.cs @@ -0,0 +1,94 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using ICSharpCode.Core; +using ICSharpCode.PythonBinding; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Configuration +{ + /// + /// Tests the AddInOptions class. + /// + [TestFixture] + public class AddInOptionsTestFixture + { + AddInOptions options; + Properties properties; + AddIn addin; + + [TestFixtureSetUp] + public void SetUpFixture() + { + addin = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree(); + addin.FileName = @"C:\Projects\SD\AddIns\Python\pythonbinding.addin"; + } + + [SetUp] + public void Init() + { + properties = new Properties(); + options = new AddInOptions(properties); + } + + [Test] + public void DefaultPythonConsoleFileNameIsPythonAddInPathCombinedWithIpyExe() + { + string expectedFileName = @"C:\Projects\SD\AddIns\Python\ipy.exe"; + Assert.AreEqual(expectedFileName, options.PythonFileName); + } + + [Test] + public void RequestingPythonFileNameWhenPythonConsoleFileNameSetToNullReturnsDefaultPythonConsoleFileName() + { + options.PythonFileName = null; + string expectedFileName = @"C:\Projects\SD\AddIns\Python\ipy.exe"; + Assert.AreEqual(expectedFileName, options.PythonFileName); + } + + [Test] + public void RequestingPythonFileNameWhenPythonConsoleFileNameToEmptyStringReturnsDefaultPythonConsoleFileName() + { + options.PythonFileName = String.Empty; + string expectedFileName = @"C:\Projects\SD\AddIns\Python\ipy.exe"; + Assert.AreEqual(expectedFileName, options.PythonFileName); + } + + [Test] + public void SetPythonConsoleFileNameUpdatesAddInOptionsPythonFileName() + { + string fileName = @"C:\IronPython\ipy.exe"; + options.PythonFileName = fileName; + Assert.AreEqual(fileName, options.PythonFileName); + } + + [Test] + public void SetPythonConsoleFileNameUpdatesProperties() + { + string fileName = @"C:\IronPython\ipy.exe"; + options.PythonFileName = fileName; + Assert.AreEqual(fileName, properties["PythonFileName"]); + } + + [Test] + public void PythonLibraryPathTakenFromProperties() + { + string expectedPythonLibraryPath = @"c:\python26\lib;c:\python26\lib\lib-tk"; + properties["PythonLibraryPath"] = expectedPythonLibraryPath; + Assert.AreEqual(expectedPythonLibraryPath, options.PythonLibraryPath); + } + + [Test] + public void DefaultPythonLibraryPathIsEmptyString() + { + Assert.AreEqual(String.Empty, options.PythonLibraryPath); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs index 32e2f86734..0939669caf 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ForLoopConversionTestFixture.cs @@ -51,7 +51,6 @@ namespace PythonBinding.Tests.Converter { NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp); string code = converter.Convert(csharp); - System.Console.WriteLine(code); string expectedCode = "class Foo(object):\r\n" + "\tdef GetCount(self):\r\n" + "\t\tcount = 0\r\n" + @@ -60,7 +59,7 @@ namespace PythonBinding.Tests.Converter "\t\t\tcount += 1\r\n" + "\t\t\ti = i + 1\r\n" + "\t\treturn count"; - + Assert.AreEqual(expectedCode, code); } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs index bf5770363e..66d959d2e8 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/ProjectHasStartupObjectTestFixture.cs @@ -17,6 +17,7 @@ using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Converter { @@ -31,7 +32,7 @@ namespace PythonBinding.Tests.Converter MSBuildBasedProject sourceProject; PythonProject targetProject; MockTextEditorProperties mockTextEditorProperties; - MockProjectContent mockProjectContent; + PythonBinding.Tests.Utils.MockProjectContent mockProjectContent; string startupObject = "RootNamespace.Main"; @@ -64,7 +65,7 @@ namespace PythonBinding.Tests.Converter // Set up IProjectContent so the ConvertProjectToPythonProjectCommand can // locate the startup object and determine it's filename. - mockProjectContent = new MockProjectContent(); + mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent(); MockClass mainClass = new MockClass(mockProjectContent, startupObject); mainClass.CompilationUnit.FileName = @"d:\projects\test\src\Main2.cs"; mockProjectContent.ClassToReturnFromGetClass = mainClass; diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs index 723eff78d7..8e1e8e9e64 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratorMergeFindsInitializeComponentsTestFixture.cs @@ -20,6 +20,7 @@ using ICSharpCode.FormsDesigner; using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Designer { @@ -71,7 +72,7 @@ namespace PythonBinding.Tests.Designer [Test] public void GetDomRegion() { - MockMethod method = new MockMethod(); + MockMethod method = new MockMethod(MockClass.CreateMockClassWithoutAnyAttributes()); DomRegion bodyRegion = new DomRegion(0, 4, 1, 4); method.BodyRegion = bodyRegion; DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs index 6e6d37d7f7..bc4b6948c9 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonDesignerLoaderTestFixture.cs @@ -68,9 +68,7 @@ namespace PythonBinding.Tests.Designer serializationManager = new DesignerSerializationManager(mockDesignerLoaderHost); - System.Console.WriteLine("Before BeginLoad"); loader.BeginLoad(mockDesignerLoaderHost); - System.Console.WriteLine("After BeginLoad"); rootComponent = mockDesignerLoaderHost.RootComponent; designedForm = new Form(); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs index 8c82afa474..e414ac077f 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/PythonGeneratorTestFixture.cs @@ -17,6 +17,7 @@ using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Designer { @@ -26,7 +27,7 @@ namespace PythonBinding.Tests.Designer [Test] public void GetMethodReplaceRegion() { - MockMethod method = new MockMethod(); + MockMethod method = new MockMethod(MockClass.CreateMockClassWithoutAnyAttributes()); DomRegion bodyRegion = new DomRegion(0, 4, 1, 4); method.BodyRegion = bodyRegion; DomRegion expectedRegion = new DomRegion(bodyRegion.BeginLine + 1, 1, bodyRegion.EndLine + 1, 1); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AppSettingsPanelTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/AppSettingsPanelTestFixture.cs similarity index 99% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/AppSettingsPanelTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/AppSettingsPanelTestFixture.cs index 2c911e6355..77c59a6125 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/AppSettingsPanelTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/AppSettingsPanelTestFixture.cs @@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { /// /// Tests the ApplicationSettingsPanel class. diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CompilingOptionsPanelTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/CompilingOptionsPanelTestFixture.cs similarity index 99% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/CompilingOptionsPanelTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/CompilingOptionsPanelTestFixture.cs index 1d10376d14..7e6b51e07f 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CompilingOptionsPanelTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/CompilingOptionsPanelTestFixture.cs @@ -16,7 +16,7 @@ using ICSharpCode.SharpDevelop.Project; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { /// /// Tests the CompilingOptionsPanel. diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs similarity index 88% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs index ed886eb6cc..eff903c3e9 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/DebugPythonCommandTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/DebugPythonCommandTestFixture.cs @@ -13,7 +13,7 @@ using ICSharpCode.PythonBinding; using PythonBinding.Tests.Utils; using NUnit.Framework; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { [TestFixture] public class DebugPythonCommandTestFixture @@ -26,7 +26,7 @@ namespace PythonBinding.Tests { // Create dummy view content with the Python script. MockViewContent viewContent = new MockViewContent(); - viewContent.PrimaryFileName = new FileName(@"C:\Projects\test.py"); + viewContent.PrimaryFileName = new FileName(@"C:\Projects\test.py"); MockWorkbenchWindow workbenchWindow = new MockWorkbenchWindow(); workbenchWindow.ActiveViewContent = viewContent; MockWorkbench workbench = new MockWorkbench(); @@ -57,7 +57,7 @@ namespace PythonBinding.Tests [Test] public void ProcessInfoArgs() { - Assert.AreEqual("-D \"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments); + Assert.AreEqual("-X:Debug \"C:\\Projects\\test.py\"", debugger.ProcessStartInfo.Arguments); } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/FormsDesignerDisplayBindingTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/FormsDesignerDisplayBindingTestFixture.cs similarity index 95% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/FormsDesignerDisplayBindingTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/FormsDesignerDisplayBindingTestFixture.cs index ae257c9c6a..6580488bc6 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/FormsDesignerDisplayBindingTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/FormsDesignerDisplayBindingTestFixture.cs @@ -8,12 +8,13 @@ using System; using ICSharpCode.FormsDesigner; using ICSharpCode.PythonBinding; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Gui; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { /// /// Tests the PythonFormsDesignerDisplayBinding. @@ -23,8 +24,8 @@ namespace PythonBinding.Tests { DerivedPythonFormsDesignerDisplayBinding displayBinding; MockTextEditorViewContent viewContent; - ParseInformation parseInfo; bool canAttachToDesignableClass; + ParseInformation parseInfo; [SetUp] public void SetUp() @@ -32,7 +33,7 @@ namespace PythonBinding.Tests displayBinding = new DerivedPythonFormsDesignerDisplayBinding(); viewContent = new MockTextEditorViewContent(); parseInfo = new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent())); - viewContent.PrimaryFileName = new ICSharpCode.Core.FileName("test.py"); + viewContent.PrimaryFileName = new FileName("test.py"); viewContent.TextEditor.Document.Text = "text content"; displayBinding.ParseServiceParseInfoToReturn = parseInfo; displayBinding.IsParseInfoDesignable = true; @@ -99,7 +100,7 @@ namespace PythonBinding.Tests [Test] public void NonPythonFileNameCannotBeAttachedTo() { - viewContent.PrimaryFileName = new ICSharpCode.Core.FileName("test.cs"); + viewContent.PrimaryFileName = new FileName("test.cs"); Assert.IsFalse(displayBinding.CanAttachTo(viewContent)); } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonIndentationTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonIndentationTests.cs similarity index 98% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonIndentationTests.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonIndentationTests.cs index 866a632a5b..9bcfc0f973 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonIndentationTests.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonIndentationTests.cs @@ -13,13 +13,13 @@ using ICSharpCode.TextEditor.Actions; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests.Indentation +namespace PythonBinding.Tests { /// /// Tests that the PythonFormattingStrategy indents the new line added after pressing the ':' character. /// [TestFixture] - public class PythonNewMethodIndentationTestFixture + public class PythonIndentationTestFixture { TextEditorControl textEditor; PythonFormattingStrategy formattingStrategy; diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonOptionsPanelTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonOptionsPanelTestFixture.cs similarity index 67% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonOptionsPanelTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonOptionsPanelTestFixture.cs index c02b17827e..e5d645ff59 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonOptionsPanelTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonOptionsPanelTestFixture.cs @@ -5,16 +5,16 @@ // $Revision$ // -using ICSharpCode.SharpDevelop.Gui.OptionPanels; using System; using System.Windows.Forms; using ICSharpCode.Core; using ICSharpCode.PythonBinding; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Gui.OptionPanels; using NUnit.Framework; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { /// /// Tests the PythonOptionsPanel. @@ -26,6 +26,7 @@ namespace PythonBinding.Tests Properties properties; AddInOptions options; TextBox fileNameTextBox; + TextBox pythonLibraryPathTextBox; [SetUp] public void SetUp() @@ -33,9 +34,11 @@ namespace PythonBinding.Tests properties = new Properties(); options = new AddInOptions(properties); options.PythonFileName = @"C:\Python\ipy.exe"; + options.PythonLibraryPath = @"C:\Python26\lib"; optionsPanel = new PythonOptionsPanel(options); optionsPanel.LoadPanelContents(); fileNameTextBox = (TextBox)optionsPanel.ControlDictionary["pythonFileNameTextBox"]; + pythonLibraryPathTextBox = (TextBox)optionsPanel.ControlDictionary["pythonLibraryPathTextBox"]; } [TearDown] @@ -47,7 +50,13 @@ namespace PythonBinding.Tests [Test] public void PythonFileNameDisplayed() { - Assert.AreEqual(options.PythonFileName, fileNameTextBox.Text); + Assert.AreEqual(@"C:\Python\ipy.exe", fileNameTextBox.Text); + } + + [Test] + public void PythonLibraryPathIsDisplayed() + { + Assert.AreEqual(@"C:\Python26\lib", pythonLibraryPathTextBox.Text); } [Test] @@ -57,12 +66,21 @@ namespace PythonBinding.Tests } [Test] - public void SaveOptions() + public void SavingOptionsUpdatesIronPythonFileName() { string fileName = @"C:\Program Files\IronPython\ipy.exe"; fileNameTextBox.Text = fileName; optionsPanel.StorePanelContents(); Assert.AreEqual(fileName, options.PythonFileName); } + + [Test] + public void SavingOptionsUpdatesIronPythonLibraryPath() + { + string path = @"c:\Program Files\Python\lib"; + pythonLibraryPathTextBox.Text = path; + optionsPanel.StorePanelContents(); + Assert.AreEqual(path, options.PythonLibraryPath); + } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonSyntaxModeTestFixture.cs similarity index 99% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonSyntaxModeTestFixture.cs index 261749e7e6..64209fb9eb 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonSyntaxModeTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/PythonSyntaxModeTestFixture.cs @@ -16,8 +16,9 @@ using ICSharpCode.AvalonEdit.AddIn; using ICSharpCode.Core; using ICSharpCode.TextEditor.Document; using NUnit.Framework; +using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { /// /// Tests the Python.xshd syntax mode information. diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTestFixture.cs similarity index 98% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTestFixture.cs index 1e5cf87015..97a148f5f5 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/RunPythonCommandTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Gui/RunPythonCommandTestFixture.cs @@ -13,7 +13,7 @@ using ICSharpCode.SharpDevelop.Gui; using NUnit.Framework; using PythonBinding.Tests.Utils; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Gui { /// /// Tests that the RunPythonCommand class runs the Python console diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs index df26c3a68d..58d3c03080 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ClassWithBaseClassTestFixture.cs @@ -52,6 +52,5 @@ namespace PythonBinding.Tests.Parsing } Assert.IsNotNull(matchedBaseType); } - } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs new file mode 100644 index 0000000000..5d479b83da --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs @@ -0,0 +1,59 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.TextEditor.Document; +using NUnit.Framework; +using PythonBinding.Tests; + +namespace PythonBinding.Tests.Parsing +{ + [TestFixture] + public class ParseClassNestedInsideMethodTestFixture + { + ICompilationUnit compilationUnit; + IClass c; + + [SetUp] + public void SetUpFixture() + { + string python = + "class MyClass:\r\n" + + " def firstMethod(self):\r\n" + + " class NestedClass:\r\n" + + " def firstNestedClassMethod(self):\r\n" + + " pass\r\n" + + "\r\n" + + " def secondMethod(self):\r\n" + + " pass\r\n" + + "\r\n"; + + DefaultProjectContent projectContent = new DefaultProjectContent(); + PythonParser parser = new PythonParser(); + compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); + if (compilationUnit.Classes.Count > 0) { + c = compilationUnit.Classes[0]; + } + } + + [Test] + public void CompilationUnitHasOneClass() + { + Assert.AreEqual(1, compilationUnit.Classes.Count); + } + + [Test] + public void MyClassHasTwoMethods() + { + Assert.AreEqual(2, c.Methods.Count); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassTestFixture.cs new file mode 100644 index 0000000000..76415f2318 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassTestFixture.cs @@ -0,0 +1,52 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace PythonBinding.Tests.Parsing +{ + [TestFixture] + public class ParseTestClassTestFixture + { + ICompilationUnit compilationUnit; + IClass c; + + [TestFixtureSetUp] + public void SetUpFixture() + { + string python = + "import unittest\r\n" + + "\r\n" + + "class simpleTest(unittest.TestCase):\r\n" + + " def testSuccess(self):\r\n" + + " assert True\r\n" + + "\r\n" + + " def testFailure(self):\r\n" + + " assert False\r\n" + + "\r\n"; + + DefaultProjectContent projectContent = new DefaultProjectContent(); + PythonParser parser = new PythonParser(); + compilationUnit = parser.Parse(projectContent, @"C:\test.py", python); + if (compilationUnit.Classes.Count > 0) { + c = compilationUnit.Classes[0]; + } + } + + [Test] + public void SimpleTestFirstBaseTypeIsUnitTestTestCase() + { + IReturnType baseType = c.BaseTypes[0]; + string actualBaseTypeName = baseType.FullyQualifiedName; + string expectedBaseTypeName = "unittest.TestCase"; + Assert.AreEqual(expectedBaseTypeName, actualBaseTypeName); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassWithBaseClassTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassWithBaseClassTestFixture.cs new file mode 100644 index 0000000000..2fe65b4a3b --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseTestClassWithBaseClassTestFixture.cs @@ -0,0 +1,89 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; + +namespace PythonBinding.Tests.Parsing +{ + [TestFixture] + public class ParseTestClassWithBaseClassTestFixture + { + ICompilationUnit compilationUnit; + IClass c; + DefaultProjectContent projectContent; + + [TestFixtureSetUp] + public void SetUpFixture() + { + string python = + "import unittest\r\n" + + "\r\n" + + "class BaseTest(unittest.TestCase):\r\n" + + " def testSuccess(self):\r\n" + + " assert True\r\n" + + "\r\n" + + "class DerivedTest(BaseTest):\r\n" + + " pass\r\n" + + "\r\n"; + + projectContent = new DefaultProjectContent(); + PythonParser parser = new PythonParser(); + string fileName = @"C:\test.py"; + compilationUnit = parser.Parse(projectContent, fileName, python); + projectContent.UpdateCompilationUnit(null, compilationUnit, fileName); + if (compilationUnit.Classes.Count > 1) { + c = compilationUnit.Classes[1]; + } + } + + [Test] + public void DerivedTestFirstBaseTypeIsBaseTestTestCase() + { + IReturnType baseType = c.BaseTypes[0]; + string actualBaseTypeName = baseType.FullyQualifiedName; + string expectedBaseTypeName = "test.BaseTest"; + Assert.AreEqual(expectedBaseTypeName, actualBaseTypeName); + } + + [Test] + public void DerivedTestBaseClassNameIsBaseTest() + { + IClass baseClass = c.BaseClass; + string actualName = baseClass.FullyQualifiedName; + string expectedName = "test.BaseTest"; + Assert.AreEqual(expectedName, actualName); + } + + [Test] + public void ProjectContentGetClassReturnsBaseTest() + { + IClass c = projectContent.GetClass("test.BaseTest", 0); + Assert.AreEqual("test.BaseTest", c.FullyQualifiedName); + } + + [Test] + public void CompilationUnitUsingScopeNamespaceNameIsNamespaceTakenFromFileName() + { + string expectedNamespace = "test"; + Assert.AreEqual(expectedNamespace, compilationUnit.UsingScope.NamespaceName); + } + + [Test] + public void DerivedTestBaseClassHasTestCaseBaseClass() + { + IReturnType baseType = c.BaseTypes[0]; + IClass baseClass = baseType.GetUnderlyingClass(); + IReturnType baseBaseType = baseClass.BaseTypes[0]; + string actualBaseTypeName = baseBaseType.FullyQualifiedName; + string expectedBaseTypeName = "unittest.TestCase"; + Assert.AreEqual(expectedBaseTypeName, actualBaseTypeName); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index 69ef73d933..a872c44704 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj @@ -79,11 +79,7 @@ - - - - @@ -104,6 +100,8 @@ + + @@ -199,7 +197,6 @@ - @@ -342,12 +339,19 @@ - - + + + + + + + + + @@ -364,12 +368,11 @@ - - - - - - + + + + + @@ -416,9 +419,22 @@ - + + + + + + + + + + + + + + @@ -426,7 +442,6 @@ - @@ -437,8 +452,9 @@ + + - @@ -447,12 +463,12 @@ - + @@ -463,6 +479,7 @@ + PythonBinding.addin @@ -472,11 +489,13 @@ + + @@ -504,6 +523,10 @@ {35CEF10F-2D4C-45F2-9DD1-161E0FEC583C} ICSharpCode.Core + + {857CA1A3-FC88-4BE0-AB6A-D1EE772AB288} + ICSharpCode.Core.WinForms + {924EE450-603D-49C1-A8E5-4AFAA31CE6F3} ICSharpCode.SharpDevelop.Dom @@ -512,6 +535,14 @@ {8035765F-D51F-4A0C-A746-2FD100E19419} ICSharpCode.SharpDevelop.Widgets + + {44A8DE09-CAB9-49D8-9CFC-5EB0A552F181} + UnitTesting.Tests + + + {1F261725-6318-4434-A1B1-6C70CE4CD324} + UnitTesting + {0162E499-42D0-409B-AA25-EED21F75336B} AvalonEdit.AddIn @@ -529,6 +560,10 @@ + + + + diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/CreateNewPythonProjectTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/CreateNewPythonProjectTestFixture.cs similarity index 100% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/CreateNewPythonProjectTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/CreateNewPythonProjectTestFixture.cs diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/ProjectBindingTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/ProjectBindingTestFixture.cs similarity index 100% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/ProjectBindingTestFixture.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/ProjectBindingTestFixture.cs diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguagePropertiesTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/PythonLanguagePropertiesTests.cs similarity index 100% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguagePropertiesTests.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonLanguage/PythonLanguagePropertiesTests.cs diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs index 09f4654490..a73cc401d6 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleFromSystemImportEverythingFixture.cs @@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom.CSharp; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs index 9cea39b099..d02815eb21 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveConsoleWriteLineTestFixture.cs @@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs index 1ffbca464d..108ba743e3 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveFooTextBoxFromSystemWindowsFormsImportedAsFooTestFixture.cs @@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom.CSharp; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs index 0db59b8a0c..9f5c872712 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalClassInstanceTestFixture.cs @@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { @@ -27,7 +28,7 @@ namespace PythonBinding.Tests.Resolver public class ResolveLocalClassInstanceTestFixture { PythonResolver resolver; - MockProjectContent mockProjectContent; + PythonBinding.Tests.Utils.MockProjectContent mockProjectContent; LocalResolveResult resolveResult; MockClass testClass; ICompilationUnit compilationUnit; @@ -37,7 +38,7 @@ namespace PythonBinding.Tests.Resolver { resolver = new PythonResolver(); - mockProjectContent = new MockProjectContent(); + mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent(); testClass = new MockClass(mockProjectContent, "Test.Test1"); mockProjectContent.ClassesInProjectContent.Add(testClass); mockProjectContent.ClassToReturnFromGetClass = testClass; diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs index 626bb6455b..0e014b791c 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemConsoleTestFixture.cs @@ -12,6 +12,7 @@ using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { @@ -23,7 +24,7 @@ namespace PythonBinding.Tests.Resolver public class ResolveSystemConsoleTestFixture { PythonResolver resolver; - MockProjectContent mockProjectContent; + PythonBinding.Tests.Utils.MockProjectContent mockProjectContent; ResolveResult resolveResult; MockClass testClass; ICompilationUnit compilationUnit; @@ -34,7 +35,7 @@ namespace PythonBinding.Tests.Resolver public void SetUpFixture() { resolver = new PythonResolver(); - mockProjectContent = new MockProjectContent(); + mockProjectContent = new PythonBinding.Tests.Utils.MockProjectContent(); systemConsoleClass = new MockClass(mockProjectContent, "System.Console"); mockProjectContent.ClassToReturnFromGetClass = systemConsoleClass; @@ -106,7 +107,7 @@ namespace PythonBinding.Tests.Resolver protected virtual ICompilationUnit CreateCompilationUnit(IProjectContent projectContent) { ICompilationUnit compilationUnit = new DefaultCompilationUnit(projectContent); - testClass = new MockClass(compilationUnit, "Test"); + testClass = new MockClass(projectContent, "Test"); compilationUnit.Classes.Add(testClass); return compilationUnit; } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs index bb7a50a2f1..7a30fb97a4 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveSystemNamespaceWithMissingImportTestFixture.cs @@ -11,6 +11,7 @@ using ICSharpCode.PythonBinding; using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs index 2f5d3448ff..6fe5b03465 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportTextBoxTestFixture.cs @@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom.CSharp; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs index 3157cd7283..304ad0fe38 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveTextBoxFromSystemWindowsFormsImportedAsMyTextBoxTestFixture.cs @@ -13,6 +13,7 @@ using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Dom.CSharp; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Resolver { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreatePythonTestRunnerTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreatePythonTestRunnerTestFixture.cs new file mode 100644 index 0000000000..09846b1aa3 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreatePythonTestRunnerTestFixture.cs @@ -0,0 +1,52 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using ICSharpCode.PythonBinding; +using NUnit.Framework; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class CreatePythonTestRunnerTestFixture + { + PythonTestFramework testFramework; + + [TestFixtureSetUp] + public void SetUpFixture() + { + if (!PropertyService.Initialized) { + PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); + } + } + + [SetUp] + public void Init() + { + testFramework = new PythonTestFramework(); + } + + [Test] + public void PythonTestFrameworkCreateTestRunnerReturnsPythonTestRunner() + { + Assert.IsInstanceOf(typeof(PythonTestRunner), testFramework.CreateTestRunner()); + } + + [Test] + public void PythonTestFrameworkCreateTestDebuggerReturnsPythonTestDebugger() + { + Assert.IsInstanceOf(typeof(PythonTestDebugger), testFramework.CreateTestDebugger()); + } + + [Test] + public void PythonTestFrameworkIsBuildNeededBeforeTestRunReturnsFalse() + { + Assert.IsFalse(testFramework.IsBuildNeededBeforeTestRun); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs new file mode 100644 index 0000000000..a0f36b8026 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterFromCreateTextWriterInfoTestFixture.cs @@ -0,0 +1,41 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; +using ICSharpCode.PythonBinding; +using NUnit.Framework; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class CreateTextWriterFromCreateTextWriterInfoTestFixture + { + TextWriter textWriter; + + [TestFixtureSetUp] + public void SetUpFixture() + { + string fileName = Path.GetTempFileName(); + CreateTextWriterInfo info = new CreateTextWriterInfo(fileName, Encoding.UTF8, false); + textWriter = info.CreateTextWriter(); + } + + [TestFixtureTearDown] + public void TearDownFixture() + { + textWriter.Dispose(); + } + + [Test] + public void CreatedTextWriterEncodingIsUtf8() + { + Assert.AreEqual(Encoding.UTF8, textWriter.Encoding); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs new file mode 100644 index 0000000000..3c8e19c2f1 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/CreateTextWriterInfoEqualsTestFixture.cs @@ -0,0 +1,57 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Text; +using ICSharpCode.PythonBinding; +using NUnit.Framework; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class CreateTextWriterInfoEqualsTestFixture + { + [Test] + public void CreateTextWriterInfosAreEqualWhenFileNameAndEncodingAndAppendAreEqual() + { + CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + Assert.AreEqual(lhs, rhs); + } + + [Test] + public void CreateTextWriterInfosAreNotEqualWhenFileNamesAreDifferent() + { + CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + CreateTextWriterInfo rhs = new CreateTextWriterInfo("different-filename.txt", Encoding.UTF8, true); + Assert.AreNotEqual(lhs, rhs); + } + + [Test] + public void CreateTextWriterInfosAreNotEqualWhenEncodingsAreDifferent() + { + CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.ASCII, true); + Assert.AreNotEqual(lhs, rhs); + } + + [Test] + public void CreateTextWriterInfosAreNotEqualWhenAppendIsDifferent() + { + CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + CreateTextWriterInfo rhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, false); + Assert.AreNotEqual(lhs, rhs); + } + + [Test] + public void CreateTextWriterInfoEqualsReturnsFalseWhenNullPassedAsParameter() + { + CreateTextWriterInfo lhs = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + Assert.IsFalse(lhs.Equals(null)); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonConsoleApplicationTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonConsoleApplicationTestFixture.cs new file mode 100644 index 0000000000..be81d28ebd --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonConsoleApplicationTestFixture.cs @@ -0,0 +1,95 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using ICSharpCode.Core; +using ICSharpCode.PythonBinding; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonConsoleApplicationTestFixture + { + PythonConsoleApplication app; + AddInOptions options; + + [SetUp] + public void Init() + { + options = new AddInOptions(new Properties()); + options.PythonFileName = @"C:\IronPython\ipy.exe"; + app = new PythonConsoleApplication(options); + } + + [Test] + public void FileNameIsPythonFileNameFromAddInOptions() + { + string expectedFileName = @"C:\IronPython\ipy.exe"; + Assert.AreEqual(expectedFileName, app.FileName); + } + + [Test] + public void GetArgumentsReturnsDebugOptionWhenDebugIsTrue() + { + app.Debug = true; + string expectedCommandLine = "-X:Debug"; + + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void GetArgumentsReturnsQuotedPythonScriptFileName() + { + app.PythonScriptFileName = @"d:\projects\my ipy\test.py"; + string expectedCommandLine = "\"d:\\projects\\my ipy\\test.py\""; + + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void GetArgumentsReturnsQuotedPythonScriptFileNameAndItsCommandLineArguments() + { + app.Debug = true; + app.PythonScriptFileName = @"d:\projects\my ipy\test.py"; + app.PythonScriptCommandLineArguments = "@responseFile.txt -def"; + string expectedCommandLine = + "-X:Debug \"d:\\projects\\my ipy\\test.py\" @responseFile.txt -def"; + + Assert.AreEqual(expectedCommandLine, app.GetArguments()); + } + + [Test] + public void GetProcessStartInfoHasFileNameThatEqualsIronPythonConsoleApplicationExeFileName() + { + ProcessStartInfo startInfo = app.GetProcessStartInfo(); + string expectedFileName = @"C:\IronPython\ipy.exe"; + + Assert.AreEqual(expectedFileName, startInfo.FileName); + } + + [Test] + public void GetProcessStartInfoHasDebugFlagSetInArguments() + { + app.Debug = true; + ProcessStartInfo startInfo = app.GetProcessStartInfo(); + string expectedCommandLine = "-X:Debug"; + + Assert.AreEqual(expectedCommandLine, startInfo.Arguments); + } + + [Test] + public void GetProcessStartInfoHasWorkingDirectoryIfSet() + { + app.WorkingDirectory = @"d:\temp"; + ProcessStartInfo startInfo = app.GetProcessStartInfo(); + Assert.AreEqual(@"d:\temp", startInfo.WorkingDirectory); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonStandardLibraryPathTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonStandardLibraryPathTests.cs new file mode 100644 index 0000000000..53835dd60f --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonStandardLibraryPathTests.cs @@ -0,0 +1,82 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Collections.Generic; +using ICSharpCode.PythonBinding; +using NUnit.Framework; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonStandardLibraryPathTests + { + [Test] + public void PathsPropertyReturnsPython26LibDirectory() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\python26\lib"); + string[] expectedPaths = new string[] { @"c:\python26\lib" }; + Assert.AreEqual(expectedPaths, path.Directories); + } + + [Test] + public void HasPathReturnsTrueForNonEmptyPathString() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\python26\lib"); + Assert.IsTrue(path.HasPath); + } + + [Test] + public void HasPathReturnsFalseForEmptyPathString() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(String.Empty); + Assert.IsFalse(path.HasPath); + } + + [Test] + public void DirectoryPropertyReturnsPython26LibDirectoryAndPython26LibTkDirectory() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\python26\lib;c:\python26\lib\lib-tk"); + string[] expectedPaths = new string[] { @"c:\python26\lib", @"c:\python26\lib\lib-tk" }; + Assert.AreEqual(expectedPaths, path.Directories); + } + + [Test] + public void DirectoryPropertyReturnsPython26LibDirectoryAndPython26LibTkDirectorySetInPathProperty() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(String.Empty); + path.Path = @"c:\python26\lib;c:\python26\lib\lib-tk"; + string[] expectedPaths = new string[] { @"c:\python26\lib", @"c:\python26\lib\lib-tk" }; + Assert.AreEqual(expectedPaths, path.Directories); + } + + [Test] + public void DirectoriesAreClearedWhenPathIsSetToDifferentValue() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\temp"); + path.Path = @"c:\python26\lib;c:\python26\lib\lib-tk"; + string[] expectedPaths = new string[] { @"c:\python26\lib", @"c:\python26\lib\lib-tk" }; + Assert.AreEqual(expectedPaths, path.Directories); + } + + [Test] + public void EmptyDirectoryInPathNotAddedToDirectories() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\temp;;c:\python\lib"); + string[] expectedPaths = new string[] { @"c:\temp", @"c:\python\lib" }; + Assert.AreEqual(expectedPaths, path.Directories); + } + + [Test] + public void DirectoryWithJustWhitespaceIsNotAddedToPath() + { + PythonStandardLibraryPath path = new PythonStandardLibraryPath(@"c:\temp; ;c:\python\lib"); + string[] expectedPaths = new string[] { @"c:\temp", @"c:\python\lib" }; + Assert.AreEqual(expectedPaths, path.Directories); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestDebuggerRunsSelectedTestMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestDebuggerRunsSelectedTestMethodTestFixture.cs new file mode 100644 index 0000000000..23a00b7809 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestDebuggerRunsSelectedTestMethodTestFixture.cs @@ -0,0 +1,156 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using ICSharpCode.Core; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestDebuggerRunsSelectedTestMethodTestFixture + { + MockDebuggerService debuggerService; + UnitTesting.Tests.Utils.MockDebugger debugger; + MockMessageService messageService; + MockCSharpProject project; + PythonTestDebugger testDebugger; + MockTestResultsMonitor testResultsMonitor; + SelectedTests selectedTests; + MockMethod methodToTest; + AddInOptions options; + MockPythonFileService fileService; + StringBuilder responseFileText; + StringWriter responseFileStringWriter; + PythonStandardLibraryPath standardLibraryPath; + + [SetUp] + public void Init() + { + CreateTestDebugger(); + CreateTestMethod(); + } + + void CreateTestDebugger() + { + debuggerService = new MockDebuggerService(); + debugger = debuggerService.MockDebugger; + messageService = new MockMessageService(); + testResultsMonitor = new MockTestResultsMonitor(); + options = new AddInOptions(new Properties()); + options.PythonFileName = @"c:\ironpython\ipy.exe"; + standardLibraryPath = new PythonStandardLibraryPath(@"c:\python\lib"); + fileService = new MockPythonFileService(); + testDebugger = new PythonTestDebugger(debuggerService, messageService, testResultsMonitor, options, standardLibraryPath, fileService); + } + + void CreateTestMethod() + { + project = new MockCSharpProject(); + MockClass c = new MockClass("MyNamespace.MyTestClass"); + methodToTest = new MockMethod(c, "MyTestMethod"); + } + + void RunTestsOnSelectedTestMethod() + { + fileService.SetTempFileName(@"d:\temp\tmp66.tmp"); + CreateTemporaryResponseFileWriter(); + + selectedTests = new SelectedTests(project, null, null, methodToTest); + testDebugger.Start(selectedTests); + } + + void CreateTemporaryResponseFileWriter() + { + responseFileText = new StringBuilder(); + responseFileStringWriter = new StringWriter(responseFileText); + fileService.SetTextWriter(responseFileStringWriter); + } + + [Test] + public void TestDebuggerProcessFileNameIsIronPythonConsoleExeTakenFromAddInOptions() + { + RunTestsOnSelectedTestMethod(); + + string expectedFileName = @"c:\ironpython\ipy.exe"; + Assert.AreEqual(expectedFileName, debugger.ProcessStartInfo.FileName); + } + + [Test] + public void DisposingTestRunnerDeletesTemporaryResponseFile() + { + fileService.FileNameDeleted = null; + RunTestsOnSelectedTestMethod(); + testDebugger.Dispose(); + + string expectedFileName = @"d:\temp\tmp66.tmp"; + Assert.AreEqual(expectedFileName, fileService.FileNameDeleted); + } + + [Test] + public void DisposingTestRunnerDisposesTestResultsMonitor() + { + RunTestsOnSelectedTestMethod(); + testDebugger.Dispose(); + Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled); + } + + [Test] + public void CommandLineArgumentHasSharpDevelopTestPythonScriptAndResponseFileName() + { + AddIn addin = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree(); + addin.FileName = @"c:\sharpdevelop\addins\pythonbinding\pythonbinding.addin"; + + RunTestsOnSelectedTestMethod(); + + string expectedCommandLine = + "-X:Debug " + + "\"c:\\sharpdevelop\\addins\\pythonbinding\\TestRunner\\sdtest.py\" " + + "\"@d:\\temp\\tmp66.tmp\""; + + Assert.AreEqual(expectedCommandLine, debugger.ProcessStartInfo.Arguments); + } + + [Test] + public void PythonTestResultReturnedFromTestFinishedEvent() + { + TestResult testResult = null; + testDebugger.TestFinished += delegate(object source, TestFinishedEventArgs e) { + testResult = e.Result; + }; + TestResult testResultToFire = new TestResult("test"); + testResultsMonitor.FireTestFinishedEvent(testResultToFire); + + Assert.IsInstanceOf(typeof(PythonTestResult), testResult); + } + + [Test] + public void ResponseFileTextContainsPythonLibraryPathFromPythonStandardLibraryPathObjectIfNotDefinedInAddInOptions() + { + standardLibraryPath.Path = @"c:\python\lib;c:\python\lib\lib-tk"; + options.PythonLibraryPath = String.Empty; + testResultsMonitor.FileName = @"c:\temp\test-results.txt"; + RunTestsOnSelectedTestMethod(); + + string expectedText = + "/p:\"c:\\python\\lib\"\r\n" + + "/p:\"c:\\python\\lib\\lib-tk\"\r\n" + + "/r:\"c:\\temp\\test-results.txt\"\r\n" + + "MyNamespace.MyTestClass.MyTestMethod\r\n"; + + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestClassTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestClassTests.cs new file mode 100644 index 0000000000..994e1a7cc9 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestClassTests.cs @@ -0,0 +1,82 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Dom; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestFrameworkIsTestClassTests + { + PythonTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new PythonTestFramework(); + } + + [Test] + public void CreateClassWithUnitTestTestCaseBaseTypeReturnsClassWithFirstBaseTypeEqualToTestCase() + { + IClass c = MockClass.CreateClassWithBaseType("unittest.TestCase"); + string name = c.BaseTypes[0].FullyQualifiedName; + string expectedName = "unittest.TestCase"; + Assert.AreEqual(expectedName, name); + } + + [Test] + public void IsTestClassReturnsTrueWhenClassFirstBaseTypeIsUnitTestTestCase() + { + MockClass c = MockClass.CreateClassWithBaseType("unittest.TestCase"); + Assert.IsTrue(testFramework.IsTestClass(c)); + } + + [Test] + public void IsTestClassReturnsFalseWhenClassHasNoBaseTypes() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + Assert.IsFalse(testFramework.IsTestClass(c)); + } + + [Test] + public void IsTestClassReturnsFalseForNull() + { + Assert.IsFalse(testFramework.IsTestClass(null)); + } + + [Test] + public void IsTestClassReturnsFalseWhenFirstBaseTypeIsSystemWindowsFormsForm() + { + MockClass c = MockClass.CreateClassWithBaseType("System.Windows.Forms.Form"); + Assert.IsFalse(testFramework.IsTestClass(c)); + } + + [Test] + public void IsTestClassReturnsTrueWhenDerivedClassHasBaseClassDerivedFromTestCase() + { + MockClass baseClass = MockClass.CreateClassWithBaseType("unittest.TestCase"); + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + DefaultReturnType returnType = new DefaultReturnType(baseClass); + c.BaseTypes.Add(returnType); + + Assert.IsTrue(testFramework.IsTestClass(c)); + } + + [Test] + public void IsTestClassReturnsTrueWhenClassFirstBaseTypeIsUnitTest2TestCase() + { + MockClass c = MockClass.CreateClassWithBaseType("unittest2.TestCase"); + Assert.IsTrue(testFramework.IsTestClass(c)); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestMethodTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestMethodTests.cs new file mode 100644 index 0000000000..1ec715060d --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestMethodTests.cs @@ -0,0 +1,49 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.PythonBinding; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestFrameworkIsTestMethodTests + { + PythonTestFramework testFramework; + + [SetUp] + public void Init() + { + testFramework = new PythonTestFramework(); + } + + [Test] + public void IsTestMethodReturnsTrueForMethodThatStartsWithTest() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + MockMethod method = new MockMethod(c, "testRunThis"); + Assert.IsTrue(testFramework.IsTestMethod(method)); + } + + [Test] + public void IsTestMethodReturnsFalseForNull() + { + Assert.IsFalse(testFramework.IsTestMethod(null)); + } + + [Test] + public void IsTestMethodReturnsFalseForMethodThatDoesNotStartWithTest() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + MockMethod method = new MockMethod(c, "RunThis"); + Assert.IsFalse(testFramework.IsTestMethod(method)); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestProjectTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestProjectTests.cs new file mode 100644 index 0000000000..f6a0a979ae --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestFrameworkIsTestProjectTests.cs @@ -0,0 +1,66 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Internal.Templates; +using ICSharpCode.SharpDevelop.Project; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestFrameworkIsTestProjectTests + { + PythonTestFramework testFramework; + + [TestFixtureSetUp] + public void SetUpFixture() + { + MSBuildEngineHelper.InitMSBuildEngine(); + } + + [SetUp] + public void Init() + { + testFramework = new PythonTestFramework(); + } + + [Test] + public void IsTestProjectReturnsFalseForNull() + { + Assert.IsFalse(testFramework.IsTestProject(null)); + } + + [Test] + public void IsTestProjectReturnsTrueForPythonProject() + { + ProjectCreateInformation createInfo = new ProjectCreateInformation(); + createInfo.Solution = new Solution(); + createInfo.OutputProjectFileName = @"C:\projects\test.pyproj"; + PythonProject project = new PythonProject(createInfo); + + Assert.IsTrue(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsFalseForNonPythonProject() + { + MockProject project = new MockProject(); + Assert.IsFalse(testFramework.IsTestProject(project)); + } + + [Test] + public void IsTestProjectReturnsFalseForNullPythonProject() + { + PythonProject project = null; + Assert.IsFalse(testFramework.IsTestProject(project)); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultFailureTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultFailureTestFixture.cs new file mode 100644 index 0000000000..24770b8d89 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultFailureTestFixture.cs @@ -0,0 +1,90 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.PythonBinding; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestResultFailureTestFixture + { + PythonTestResult pythonTestResult; + string stackTraceText; + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyTest"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "test failed"; + + stackTraceText = + "Traceback (most recent call last):\r\n" + + " File \"d:\\temp\\test\\PyTests\\Tests\\MyClassTest.py\", line 16, in testAssertEquals\r\n" + + " self.assertEqual(10, 15, 'wrong size after resize')\r\n" + + "AssertionError: wrong size after resize"; + + testResult.StackTrace = stackTraceText; + pythonTestResult = new PythonTestResult(testResult); + } + + [Test] + public void TestResultNameIsMyTest() + { + Assert.AreEqual("MyTest", pythonTestResult.Name); + } + + [Test] + public void TestResultTypeIsFailure() + { + Assert.AreEqual(TestResultType.Failure, pythonTestResult.ResultType); + } + + [Test] + public void TestResultMessageIsTestFailed() + { + Assert.AreEqual("test failed", pythonTestResult.Message); + } + + [Test] + public void PythonTestResultHasStackTraceFromOriginalTestResult() + { + Assert.AreEqual(stackTraceText, pythonTestResult.StackTrace); + } + + [Test] + public void StackTraceFilePositionHasExpectedFileName() + { + string expectedFileName = "d:\\temp\\test\\PyTests\\Tests\\MyClassTest.py"; + Assert.AreEqual(expectedFileName, pythonTestResult.StackTraceFilePosition.FileName); + } + + [Test] + public void StackTraceFilePositionLineIs16() + { + Assert.AreEqual(16, pythonTestResult.StackTraceFilePosition.Line); + } + + [Test] + public void StackTraceFilePositionColumnIsOne() + { + Assert.AreEqual(1, pythonTestResult.StackTraceFilePosition.Column); + } + + [Test] + public void ChangingStackTraceToEmptyStringSetsStackTraceFilePositionToEmpty() + { + pythonTestResult.StackTraceFilePosition = new FilePosition("test.cs", 10, 2); + pythonTestResult.StackTrace = String.Empty; + Assert.IsTrue(pythonTestResult.StackTraceFilePosition.IsEmpty); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultStackTraceLineNumberOverflowTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultStackTraceLineNumberOverflowTestFixture.cs new file mode 100644 index 0000000000..3dcfd3dd04 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestResultStackTraceLineNumberOverflowTestFixture.cs @@ -0,0 +1,44 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.PythonBinding; +using ICSharpCode.UnitTesting; +using NUnit.Framework; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestResultLineNumberOverflowTestFixture + { + PythonTestResult pythonTestResult; + string stackTraceText; + + [SetUp] + public void Init() + { + TestResult testResult = new TestResult("MyTest"); + testResult.ResultType = TestResultType.Failure; + testResult.Message = "test failed"; + + stackTraceText = + "Traceback (most recent call last):\r\n" + + " File \"d:\\temp\\test\\PyTests\\Tests\\MyClassTest.py\", line 4294967296, in testAssertEquals\r\n" + + " self.assertEqual(10, 15, 'wrong size after resize')\r\n" + + "AssertionError: wrong size after resize"; + + testResult.StackTrace = stackTraceText; + pythonTestResult = new PythonTestResult(testResult); + } + + [Test] + public void StackTraceFilePositionIsEmpty() + { + Assert.IsTrue(pythonTestResult.StackTraceFilePosition.IsEmpty); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerResponseFileTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerResponseFileTestFixture.cs new file mode 100644 index 0000000000..57b1ff8486 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerResponseFileTestFixture.cs @@ -0,0 +1,206 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; +using ICSharpCode.Core.Services; +using ICSharpCode.PythonBinding; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Project; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestRunnerResponseFileTestFixture + { + PythonTestRunnerResponseFile responseFile; + StringBuilder responseFileText; + StringWriter writer; + + [SetUp] + public void Init() + { + responseFileText = new StringBuilder(); + writer = new StringWriter(responseFileText); + responseFile = new PythonTestRunnerResponseFile(writer); + } + + [Test] + public void WriteTestAddsTestNameToResponseFile() + { + responseFile.WriteTest("MyTests"); + + Assert.AreEqual("MyTests\r\n", responseFileText.ToString()); + } + + [Test] + public void WritePathAddsQuotedSysPathCommandLineArgument() + { + responseFile.WritePath(@"c:\mytests"); + + string expectedText = "/p:\"c:\\mytests\"\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void WriteResultsFileNameAddsQuotedResultsFileNameCommandLineArgument() + { + responseFile.WriteResultsFileName(@"c:\temp\tmp66.tmp"); + + string expectedText = "/r:\"c:\\temp\\tmp66.tmp\"\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void DisposeMethodDisposesTextWriterPassedInConstructor() + { + responseFile.Dispose(); + Assert.Throws(delegate { writer.Write("test"); }); + } + + [Test] + public void WriteTestsWritesSelectedTestMethodNameWhenMethodSelected() + { + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.FullyQualifiedName = "MyNamespace.MyTests.MyTestMethod"; + SelectedTests tests = new SelectedTests(new MockCSharpProject(), null, null, method); + + responseFile.WriteTests(tests); + + string expectedText = "MyNamespace.MyTests.MyTestMethod\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void WriteTestsWritesSelectedTestClassNameWhenOnlyClassSelected() + { + MockClass c = MockClass.CreateMockClassWithoutAnyAttributes(); + c.FullyQualifiedName = "MyNamespace.MyTests"; + SelectedTests tests = new SelectedTests(new MockCSharpProject(), null, c, null); + + responseFile.WriteTests(tests); + + string expectedText = "MyNamespace.MyTests\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void WriteTestsWritesSelectedTestNamespaceWhenOnlyNamespaceSelected() + { + SelectedTests tests = new SelectedTests(new MockCSharpProject(), "MyNamespace", null, null); + responseFile.WriteTests(tests); + + string expectedText = "MyNamespace\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void WriteTestsWritesNamespacesForAllFilesInProjectWhenOnlyProjectSelected() + { + MockCSharpProject project = new MockCSharpProject(); + + FileProjectItem item = new FileProjectItem(project, ItemType.Compile); + item.FileName = @"c:\projects\mytests\nonTestClass.py"; + ProjectService.AddProjectItem(project, item); + + item = new FileProjectItem(project, ItemType.Compile); + item.FileName = @"c:\projects\mytests\TestClass.py"; + ProjectService.AddProjectItem(project, item); + + SelectedTests tests = new SelectedTests(project); + + responseFile.WriteTests(tests); + + string expectedText = + "nonTestClass\r\n" + + "TestClass\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void WriteTestsWritesNothingToResponseFileWhenMethodAndClassAndNamespaceAndProjectIsNull() + { + SelectedTests tests = new SelectedTests(null); + responseFile.WriteTests(tests); + Assert.AreEqual(String.Empty, responseFileText.ToString()); + } + + [Test] + public void WriteTestsDoesNotThrowNullReferenceExceptionWhenNonFileProjectItemInProject() + { + MockCSharpProject project = new MockCSharpProject(); + WebReferenceUrl webRef = new WebReferenceUrl(project); + webRef.Include = "test"; + ProjectService.AddProjectItem(project, webRef); + + FileProjectItem item = new FileProjectItem(project, ItemType.Compile); + item.FileName = @"c:\projects\mytests\myTests.py"; + ProjectService.AddProjectItem(project, item); + + SelectedTests tests = new SelectedTests(project); + responseFile.WriteTests(tests); + + string expectedText = "myTests\r\n"; + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void WriteTestsWritesDirectoriesForReferencedProjectsToSysPathCommandLineArguments() + { + // Have to initialize the workbench since ProjectReferenceProjectItem has a dependency on + // WorkbenchSingleton. + InitializeWorkbench(); + + MockCSharpProject referencedProject = new MockCSharpProject(); + referencedProject.FileName = @"c:\projects\pyproject\pyproject.pyproj"; + + MockCSharpProject unitTestProject = new MockCSharpProject(); + ProjectReferenceProjectItem projectRef = new ProjectReferenceProjectItem(unitTestProject, referencedProject); + projectRef.FileName = @"c:\projects\pyproject\pyproject.pyproj"; + ProjectService.AddProjectItem(unitTestProject, projectRef); + + MockMethod method = MockMethod.CreateMockMethodWithoutAnyAttributes(); + method.FullyQualifiedName = "MyNamespace.MyTests.MyTestMethod"; + + SelectedTests tests = new SelectedTests(unitTestProject, null, null, method); + responseFile.WriteTests(tests); + + string expectedText = + "/p:\"c:\\projects\\pyproject\"\r\n" + + "MyNamespace.MyTests.MyTestMethod\r\n"; + + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + void InitializeWorkbench() + { + string addInXml = + "\r\n" + + "\r\n" + + " \r\n" + + "\r\n" + + "\r\n " + + ""; + AddIn addin = AddIn.Load(new StringReader(addInXml)); + addin.Enabled = true; + AddInTree.InsertAddIn(addin); + if (!PropertyService.Initialized) { + PropertyService.InitializeService(String.Empty, String.Empty, String.Empty); + } + DummyServiceManager serviceManager = new DummyServiceManager(); + ServiceManager.Instance = serviceManager; + WorkbenchSingleton.InitializeWorkbench(new MockWorkbench(), null); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs new file mode 100644 index 0000000000..38fce06d8d --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Testing/PythonTestRunnerRunsSelectedTestMethodTestFixture.cs @@ -0,0 +1,225 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Diagnostics; +using System.IO; +using System.Text; +using ICSharpCode.Core; +using ICSharpCode.PythonBinding; +using ICSharpCode.SharpDevelop.Dom; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.UnitTesting; +using NUnit.Framework; +using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; + +namespace PythonBinding.Tests.Testing +{ + [TestFixture] + public class PythonTestRunnerRunsSelectedTestMethodTestFixture + { + MockCSharpProject project; + PythonTestRunner testRunner; + MockProcessRunner processRunner; + MockTestResultsMonitor testResultsMonitor; + SelectedTests selectedTests; + MockMethod methodToTest; + AddInOptions options; + MockPythonFileService fileService; + StringBuilder responseFileText; + StringWriter responseFileStringWriter; + PythonStandardLibraryPath standardLibraryPath; + + [SetUp] + public void Init() + { + CreateTestRunner(); + CreateTestMethod(); + } + + void CreateTestRunner() + { + processRunner = new MockProcessRunner(); + testResultsMonitor = new MockTestResultsMonitor(); + options = new AddInOptions(new Properties()); + options.PythonFileName = @"c:\ironpython\ipy.exe"; + fileService = new MockPythonFileService(); + standardLibraryPath = new PythonStandardLibraryPath(@"c:\python\lib"); + + testRunner = new PythonTestRunner(processRunner, testResultsMonitor, options, standardLibraryPath, fileService); + } + + void CreateTestMethod() + { + project = new MockCSharpProject(); + MockClass c = new MockClass("MyNamespace.MyTestClass"); + methodToTest = new MockMethod(c, "MyTestMethod"); + } + + void RunTestsOnSelectedTestMethod() + { + fileService.SetTempFileName(@"d:\temp\tmp66.tmp"); + CreateTemporaryResponseFileWriter(); + + selectedTests = new SelectedTests(project, null, null, methodToTest); + testRunner.Start(selectedTests); + } + + void CreateTemporaryResponseFileWriter() + { + responseFileText = new StringBuilder(); + responseFileStringWriter = new StringWriter(responseFileText); + fileService.SetTextWriter(responseFileStringWriter); + } + + [Test] + public void TestRunnerProcessFileNameIsIronPythonConsoleExeTakenFromAddInOptions() + { + RunTestsOnSelectedTestMethod(); + + string expectedFileName = @"c:\ironpython\ipy.exe"; + Assert.AreEqual(expectedFileName, processRunner.CommandPassedToStartMethod); + } + + [Test] + public void CommandLineArgumentHasSharpDevelopTestPythonScriptAndResponseFileName() + { + AddIn addin = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree(); + addin.FileName = @"c:\sharpdevelop\addins\pythonbinding\pythonbinding.addin"; + + RunTestsOnSelectedTestMethod(); + + string expectedCommandLine = + "\"c:\\sharpdevelop\\addins\\pythonbinding\\TestRunner\\sdtest.py\" " + + "\"@d:\\temp\\tmp66.tmp\""; + + Assert.AreEqual(expectedCommandLine, processRunner.CommandArgumentsPassedToStartMethod); + } + + [Test] + public void ResponseFileCreatedUsingTempFileName() + { + RunTestsOnSelectedTestMethod(); + + Assert.AreEqual(@"d:\temp\tmp66.tmp", fileService.CreateTextWriterInfoPassedToCreateTextWriter.FileName); + } + + [Test] + public void ResponseFileCreatedWithUtf8Encoding() + { + RunTestsOnSelectedTestMethod(); + + Assert.AreEqual(Encoding.UTF8, fileService.CreateTextWriterInfoPassedToCreateTextWriter.Encoding); + } + + [Test] + public void ResponseFileCreatedWithAppendSetToFalse() + { + RunTestsOnSelectedTestMethod(); + + Assert.IsFalse(fileService.CreateTextWriterInfoPassedToCreateTextWriter.Append); + } + + [Test] + public void DisposingTestRunnerDeletesTemporaryResponseFile() + { + fileService.FileNameDeleted = null; + RunTestsOnSelectedTestMethod(); + testRunner.Dispose(); + + string expectedFileName = @"d:\temp\tmp66.tmp"; + Assert.AreEqual(expectedFileName, fileService.FileNameDeleted); + } + + [Test] + public void DisposingTestRunnerDisposesTestResultsMonitor() + { + RunTestsOnSelectedTestMethod(); + testRunner.Dispose(); + Assert.IsTrue(testResultsMonitor.IsDisposeMethodCalled); + } + + [Test] + public void ResponseFileTextContainsPythonLibraryPathAndTestResultsFileNameAndFullyQualifiedTestMethod() + { + standardLibraryPath.Path = String.Empty; + options.PythonLibraryPath = @"c:\python26\lib"; + testResultsMonitor.FileName = @"c:\temp\test-results.txt"; + RunTestsOnSelectedTestMethod(); + + string expectedText = + "/p:\"c:\\python26\\lib\"\r\n" + + "/r:\"c:\\temp\\test-results.txt\"\r\n" + + "MyNamespace.MyTestClass.MyTestMethod\r\n"; + + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void ResponseFileTextDoesNotContainPythonLibraryPathIfItIsAnEmptyString() + { + options.PythonLibraryPath = String.Empty; + standardLibraryPath.Path = String.Empty; + testResultsMonitor.FileName = @"c:\temp\test-results.txt"; + RunTestsOnSelectedTestMethod(); + + string expectedText = + "/r:\"c:\\temp\\test-results.txt\"\r\n" + + "MyNamespace.MyTestClass.MyTestMethod\r\n"; + + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void ResponseFileTextContainsPythonLibraryPathFromPythonStandardLibraryPathObjectIfNotDefinedInAddInOptions() + { + standardLibraryPath.Path = @"c:\python\lib"; + options.PythonLibraryPath = String.Empty; + testResultsMonitor.FileName = @"c:\temp\test-results.txt"; + RunTestsOnSelectedTestMethod(); + + string expectedText = + "/p:\"c:\\python\\lib\"\r\n" + + "/r:\"c:\\temp\\test-results.txt\"\r\n" + + "MyNamespace.MyTestClass.MyTestMethod\r\n"; + + Assert.AreEqual(expectedText, responseFileText.ToString()); + } + + [Test] + public void ResponseFileTextWriterDisposedAfterTestsRun() + { + RunTestsOnSelectedTestMethod(); + Assert.Throws(delegate { responseFileStringWriter.Write("test"); }); + } + + [Test] + public void ProcessRunnerWorkingDirectoryIsDirectoryContainingProject() + { + RunTestsOnSelectedTestMethod(); + + string expectedDirectory = @"c:\projects\MyTests"; + string actualDirectory = processRunner.WorkingDirectory; + + Assert.AreEqual(expectedDirectory, actualDirectory); + } + + [Test] + public void PythonTestResultReturnedFromTestFinishedEvent() + { + TestResult testResult = null; + testRunner.TestFinished += delegate(object source, TestFinishedEventArgs e) { + testResult = e.Result; + }; + TestResult testResultToFire = new TestResult("test"); + testResultsMonitor.FireTestFinishedEvent(testResultToFire); + + Assert.IsInstanceOf(typeof(PythonTestResult), testResult); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/AddInPathHelper.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/AddInPathHelper.cs new file mode 100644 index 0000000000..3b2722db3c --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/AddInPathHelper.cs @@ -0,0 +1,60 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using ICSharpCode.Core; + +namespace PythonBinding.Tests.Utils +{ + public static class AddInPathHelper + { + public static AddIn CreateDummyPythonAddInInsideAddInTree() + { + RemoveOldAddIn(); + AddIn addin = CreateAddIn(); + AddInTree.InsertAddIn(addin); + return addin; + } + + static void RemoveOldAddIn() + { + AddIn oldAddin = FindOldAddIn(); + if (oldAddin != null) { + AddInTree.RemoveAddIn(oldAddin); + } + } + + static AddIn FindOldAddIn() + { + foreach (AddIn addin in AddInTree.AddIns) { + if (addin.Manifest.PrimaryIdentity == "ICSharpCode.PythonBinding") { + return addin; + } + } + return null; + } + + static AddIn CreateAddIn() + { + string xml = GetAddInXml(); + AddIn addin = AddIn.Load(new StringReader(xml)); + addin.FileName = @"C:\SharpDevelop\AddIns\PythonBinding\PythonBinding.addin"; + return addin; + } + + static string GetAddInXml() + { + return + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""; + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedAddInOptions.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedAddInOptions.cs deleted file mode 100644 index 00f3dee1ec..0000000000 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedAddInOptions.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using ICSharpCode.Core; -using ICSharpCode.PythonBinding; - -namespace PythonBinding.Tests.Utils -{ - /// - /// Overrides the AddInOptions GetAddInPath method to return - /// some dummy data used for testing. - /// - public class DerivedAddInOptions : AddInOptions - { - string addInPath = String.Empty; - string addInPathRequested = String.Empty; - - public DerivedAddInOptions(Properties properties) : base(properties) - { - } - - /// - /// Gets the addin path string passed to the GetAddInPath method. - /// - public string AddInPathRequested { - get { return addInPathRequested; } - } - - /// - /// Gets or sets the addin path that should be returned from the - /// GetAddInPath method. - /// - public string AddInPath { - get { return addInPath; } - set { addInPath = value; } - } - - /// - /// Returns our dummy AddInPath. - /// - protected override string GetAddInPath(string addIn) - { - addInPathRequested = addIn; - return addInPath; - } - } -} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs index 9847bb2e27..66a14d1bbe 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DerivedPythonDesignerLoader.cs @@ -35,7 +35,6 @@ namespace PythonBinding.Tests.Utils protected override void OnEndLoad(bool successful, ICollection errors) { - System.Console.WriteLine("DesignerLoader.OnEndLoad: successful: " + successful); if (errors != null) { foreach (object o in errors) { Exception ex = o as Exception; @@ -49,22 +48,17 @@ namespace PythonBinding.Tests.Utils protected override void OnBeginLoad() { - System.Console.WriteLine("DesignerLoader.OnBeginLoad"); base.OnBeginLoad(); } protected override void Initialize() { - System.Console.WriteLine("DesignerLoader.Initialize"); base.Initialize(); } protected override void PerformLoad(IDesignerSerializationManager manager) { - System.Console.WriteLine("DesignerLoader.PerformLoad Before"); base.PerformLoad(manager); - System.Console.WriteLine("DesignerLoader.PerformLoad After"); } - } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummyServiceManager.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummyServiceManager.cs new file mode 100644 index 0000000000..a63456cfc9 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummyServiceManager.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Windows.Forms; +using ICSharpCode.Core.Services; +using ICSharpCode.Core.WinForms; + +namespace PythonBinding.Tests.Utils +{ + public class DummyServiceManager : ServiceManager + { + WinFormsMessageService messageService = new WinFormsMessageService(); + + public DummyServiceManager() + { + } + + public override IMessageService MessageService { + get { return messageService; } + } + + public override object GetService(Type serviceType) + { + return null; + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummySynchronizeInvoke.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummySynchronizeInvoke.cs new file mode 100644 index 0000000000..07a4dbf4fc --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DummySynchronizeInvoke.cs @@ -0,0 +1,38 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.ComponentModel; + +namespace PythonBinding.Tests.Utils +{ + public class DummySynchronizeInvoke : ISynchronizeInvoke + { + public DummySynchronizeInvoke() + { + } + + public bool InvokeRequired { + get { return false; } + } + + public IAsyncResult BeginInvoke(Delegate method, object[] args) + { + return null; + } + + public object EndInvoke(IAsyncResult result) + { + return null; + } + + public object Invoke(Delegate method, object[] args) + { + return null; + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockClass.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockClass.cs deleted file mode 100644 index f3dce124e0..0000000000 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockClass.cs +++ /dev/null @@ -1,31 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; - -namespace PythonBinding.Tests.Utils -{ - /// - /// Mock implementation of the IClass interface - /// - public class MockClass : DefaultClass - { - // derive from real DefaultClass. The resolver is free to access any information from the class, - // and I don't want to have to adjust the mock whenever something in SharpDevelop.Dom changes. - public MockClass(ICompilationUnit cu, string name) - : base(cu, name) - { - } - - public MockClass(IProjectContent pc, string name) - : base(new DefaultCompilationUnit(pc), name) - { - } - } -} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs index 4c3ccf4f85..d50bc05ed6 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockDesignerLoaderHost.cs @@ -86,7 +86,6 @@ namespace PythonBinding.Tests.Utils public void EndLoad(string baseClassName, bool successful, ICollection errorCollection) { - System.Console.WriteLine("DesignerLoaderHost.EndLoad"); } public void Reload() @@ -133,13 +132,11 @@ namespace PythonBinding.Tests.Utils public Type GetType(string typeName) { - System.Console.WriteLine("DesignerLoaderHost.GetType: " + typeName); return typeResolutionService.GetType(typeName); } public void AddService(Type serviceType, object serviceInstance) { - System.Console.WriteLine("DesignerLoaderHost.AddService: " + serviceType.Name + " IsNull: " + (serviceInstance == null)); serviceContainer.AddService(serviceType, serviceInstance); } @@ -165,7 +162,6 @@ namespace PythonBinding.Tests.Utils public object GetService(Type serviceType) { - System.Console.WriteLine("DesignerLoaderHost.GetService: " + serviceType.Name); return serviceContainer.GetService(serviceType); } @@ -203,7 +199,7 @@ namespace PythonBinding.Tests.Utils TransactionOpened(this, e); } } - + protected virtual void OnTransactionOpening(EventArgs e) { if (TransactionOpening != null) { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs deleted file mode 100644 index 6e4bd60dcd..0000000000 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockMethod.cs +++ /dev/null @@ -1,297 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using ICSharpCode.SharpDevelop.Dom; - -namespace PythonBinding.Tests.Utils -{ - /// - /// Mock IMethod implementation. - /// - public class MockMethod : IMethod - { - public MockMethod() - { - } - - public DomRegion BodyRegion { get; set; } - - public IList TypeParameters { - get { - throw new NotImplementedException(); - } - } - - public bool IsConstructor { - get { - throw new NotImplementedException(); - } - } - - public bool IsOperator { - get { - throw new NotImplementedException(); - } - } - - public IList HandlesClauses { - get { - throw new NotImplementedException(); - } - } - - public IList Parameters { - get { - throw new NotImplementedException(); - } - } - - public bool IsExtensionMethod { - get { - throw new NotImplementedException(); - } - } - - public string FullyQualifiedName { - get { - throw new NotImplementedException(); - } - } - - public IReturnType DeclaringTypeReference { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IMember GenericMember { - get { - throw new NotImplementedException(); - } - } - - public DomRegion Region { - get { - throw new NotImplementedException(); - } - } - - public string Name { - get { - throw new NotImplementedException(); - } - } - - public string Namespace { - get { - throw new NotImplementedException(); - } - } - - public string DotNetName { - get { - throw new NotImplementedException(); - } - } - - public IReturnType ReturnType { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public IList InterfaceImplementations { - get { - throw new NotImplementedException(); - } - } - - public IClass DeclaringType { - get { - throw new NotImplementedException(); - } - } - - public ModifierEnum Modifiers { - get { - throw new NotImplementedException(); - } - } - - public IList Attributes { - get { - throw new NotImplementedException(); - } - } - - public string Documentation { - get { - throw new NotImplementedException(); - } - } - - public bool IsAbstract { - get { - throw new NotImplementedException(); - } - } - - public bool IsSealed { - get { - throw new NotImplementedException(); - } - } - - public bool IsStatic { - get { - throw new NotImplementedException(); - } - } - - public bool IsConst { - get { - throw new NotImplementedException(); - } - } - - public bool IsVirtual { - get { - throw new NotImplementedException(); - } - } - - public bool IsPublic { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtected { - get { - throw new NotImplementedException(); - } - } - - public bool IsPrivate { - get { - throw new NotImplementedException(); - } - } - - public bool IsInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsReadonly { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtectedAndInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsProtectedOrInternal { - get { - throw new NotImplementedException(); - } - } - - public bool IsOverride { - get { - throw new NotImplementedException(); - } - } - - public bool IsOverridable { - get { - throw new NotImplementedException(); - } - } - - public bool IsNew { - get { - throw new NotImplementedException(); - } - } - - public bool IsSynthetic { - get { - throw new NotImplementedException(); - } - } - - public object UserData { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } - } - - public bool IsFrozen { - get { - throw new NotImplementedException(); - } - } - - public IMember CreateSpecializedMember() - { - throw new NotImplementedException(); - } - - public bool IsAccessible(IClass callingClass, bool isClassInInheritanceTree) - { - throw new NotImplementedException(); - } - - public void Freeze() - { - throw new NotImplementedException(); - } - - public int CompareTo(object obj) - { - throw new NotImplementedException(); - } - - public object Clone() - { - throw new NotImplementedException(); - } - - public ICompilationUnit CompilationUnit { - get { - throw new NotImplementedException(); - } - } - - public IProjectContent ProjectContent { - get { - throw new NotImplementedException(); - } - } - - public EntityType EntityType { - get { return EntityType.Method; } - } - } -} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs index 2f539513a0..2eda8dc834 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockProject.cs @@ -292,7 +292,7 @@ namespace PythonBinding.Tests.Utils throw new NotImplementedException(); } - public void StartBuild(ThreadSafeServiceContainer serviceContainer, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) + public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { throw new NotImplementedException(); } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs new file mode 100644 index 0000000000..27a1998081 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockPythonFileService.cs @@ -0,0 +1,58 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; +using ICSharpCode.PythonBinding; + +namespace PythonBinding.Tests.Utils +{ + public class MockPythonFileService : IPythonFileService + { + CreateTextWriterInfo createTextWriterInfoPassedToCreateTextWriter; + string tempFileName; + TextWriter textWriter; + string fileNameDeleted; + + public void SetTempFileName(string fileName) + { + this.tempFileName = fileName; + } + + public string GetTempFileName() + { + return tempFileName; + } + + public void SetTextWriter(TextWriter writer) + { + this.textWriter = writer; + } + + public TextWriter CreateTextWriter(CreateTextWriterInfo textWriterInfo) + { + createTextWriterInfoPassedToCreateTextWriter = textWriterInfo; + return textWriter; + } + + public CreateTextWriterInfo CreateTextWriterInfoPassedToCreateTextWriter { + get { return createTextWriterInfoPassedToCreateTextWriter; } + set { createTextWriterInfoPassedToCreateTextWriter = value; } + } + + public void DeleteFile(string fileName) + { + fileNameDeleted = fileName; + } + + public string FileNameDeleted { + get { return fileNameDeleted; } + set { fileNameDeleted = value; } + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs index cf9ffde229..d52e52cf7b 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockTypeResolutionService.cs @@ -43,7 +43,6 @@ namespace PythonBinding.Tests.Utils public Type GetType(string name) { - System.Console.WriteLine("TypeResolutionService.GetType: " + name); lastTypeNameResolved = name; if (name == "Form") { return typeof(Form); diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs index 6310d8b40f..a461e47415 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbench.cs @@ -19,6 +19,9 @@ namespace PythonBinding.Tests.Utils /// public class MockWorkbench : IWorkbench { + DummySynchronizeInvoke synchronizeInvoke = new DummySynchronizeInvoke(); + Form form = new Form(); + public event EventHandler ActiveWorkbenchWindowChanged { add {} remove {} } public event EventHandler ActiveViewContentChanged { add {} remove {} } public event EventHandler ActiveContentChanged { add {} remove {} } @@ -26,11 +29,11 @@ namespace PythonBinding.Tests.Utils public event ViewContentEventHandler ViewClosed { add {} remove {} } public IWin32Window MainWin32Window { - get { return null; } + get { return form; } } public System.ComponentModel.ISynchronizeInvoke SynchronizingObject { - get { return null; } + get { return synchronizeInvoke; } } public System.Windows.Window MainWindow { @@ -90,12 +93,8 @@ namespace PythonBinding.Tests.Utils } public IWorkbenchLayout WorkbenchLayout { - get { - throw new NotImplementedException(); - } - set { - throw new NotImplementedException(); - } + get { return null; } + set { } } public bool IsActiveWindow { @@ -106,7 +105,6 @@ namespace PythonBinding.Tests.Utils public void Initialize() { - throw new NotImplementedException(); } public void ShowView(IViewContent content) @@ -156,7 +154,6 @@ namespace PythonBinding.Tests.Utils public void SetMemento(Properties memento) { - throw new NotImplementedException(); } public bool FullScreen { diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs index e9bc14bd9f..4687833673 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/MockWorkbenchWindow.cs @@ -90,7 +90,7 @@ namespace PythonBinding.Tests.Utils } } - public System.Windows.Media.Imaging.BitmapSource Icon { + public System.Windows.Media.ImageSource Icon { get { throw new NotImplementedException(); } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBindingAddInFile.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/PythonBindingAddInFile.cs similarity index 96% rename from src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBindingAddInFile.cs rename to src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/PythonBindingAddInFile.cs index bedd439175..c41cc5fc74 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBindingAddInFile.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/PythonBindingAddInFile.cs @@ -10,7 +10,7 @@ using System.IO; using System.Reflection; using System.Xml; -namespace PythonBinding.Tests +namespace PythonBinding.Tests.Utils { /// /// Utility class that reads the PythonBinding.addin file diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs new file mode 100644 index 0000000000..ceeb152e46 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/AddInPathHelperTestFixture.cs @@ -0,0 +1,50 @@ +// +// +// +// +// $Revision$ +// + +using System; +using ICSharpCode.Core; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Utils.Tests +{ + [TestFixture] + public class AddInPathHelperTestFixture + { + AddIn pythonAddIn; + + [SetUp] + public void Init() + { + pythonAddIn = AddInPathHelper.CreateDummyPythonAddInInsideAddInTree(); + } + + [Test] + public void AddInFileNameIsCDriveSharpDevelopAddInsPythonBindingPythonBindingAddIn() + { + string expectedFileName = @"C:\SharpDevelop\AddIns\PythonBinding\PythonBinding.addin"; + Assert.AreEqual(expectedFileName, pythonAddIn.FileName); + } + + [Test] + public void StringParserAddInPathIsCDriveSharpDevelopAddInsPythonBindingForPythonBindingAddIn() + { + string directory = StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}"); + string expectedDirectory = @"C:\SharpDevelop\AddIns\PythonBinding"; + Assert.AreEqual(expectedDirectory, directory); + } + + [Test] + public void ChangingAddInFileNameReturnsExpectedFileNameFromStringParserAddInPath() + { + pythonAddIn.FileName = @"c:\def\pythonbinding.addin"; + string expectedDirectory = @"c:\def"; + string actualDirectory = StringParser.Parse("${addinpath:ICSharpCode.PythonBinding}"); + Assert.AreEqual(expectedDirectory, actualDirectory); + } + } +} diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs index f3e04c8f35..bd3b3e4339 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockProjectContentTests.cs @@ -11,19 +11,20 @@ using ICSharpCode.PythonBinding; using ICSharpCode.SharpDevelop.Dom; using NUnit.Framework; using PythonBinding.Tests.Utils; +using UnitTesting.Tests.Utils; namespace PythonBinding.Tests.Utils.Tests { [TestFixture] public class MockProjectContentTests { - MockProjectContent projectContent; + PythonBinding.Tests.Utils.MockProjectContent projectContent; List items; [SetUp] public void Init() { - projectContent = new MockProjectContent(); + projectContent = new PythonBinding.Tests.Utils.MockProjectContent(); items = new List(); } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockPythonFileServiceTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockPythonFileServiceTestFixture.cs new file mode 100644 index 0000000000..0b068bd50a --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/Tests/MockPythonFileServiceTestFixture.cs @@ -0,0 +1,65 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.IO; +using System.Text; +using ICSharpCode.PythonBinding; +using NUnit.Framework; + +namespace PythonBinding.Tests.Utils.Tests +{ + [TestFixture] + public class MockPythonFileServiceTestFixture + { + MockPythonFileService fileService; + + [SetUp] + public void Init() + { + fileService = new MockPythonFileService(); + } + + [Test] + public void GetTempFileNameReturnsReturnsTemporaryFileName() + { + string expectedFileName = @"c:\temp\tmp1.tmp"; + fileService.SetTempFileName(expectedFileName); + string tempFileName = fileService.GetTempFileName(); + Assert.AreEqual(expectedFileName, tempFileName); + } + + [Test] + public void TextWriterReturnedFromCreateTextWriter() + { + using (StringWriter stringWriter = new StringWriter(new StringBuilder())) { + fileService.SetTextWriter(stringWriter); + CreateTextWriterInfo info = new CreateTextWriterInfo(@"test.tmp", Encoding.UTF8, true); + Assert.AreEqual(stringWriter, fileService.CreateTextWriter(info)); + } + } + + [Test] + public void CreateTextWriterInfoIsSavedWhenCreateTextWriterMethodIsCalled() + { + fileService.CreateTextWriterInfoPassedToCreateTextWriter = null; + CreateTextWriterInfo info = new CreateTextWriterInfo("test.txt", Encoding.UTF8, true); + fileService.CreateTextWriter(info); + Assert.AreEqual(info, fileService.CreateTextWriterInfoPassedToCreateTextWriter); + } + + [Test] + public void DeleteFileSavesFileNameDeleted() + { + fileService.FileNameDeleted = null; + string expectedFileName = @"c:\temp\tmp66.tmp"; + fileService.DeleteFile(expectedFileName); + + Assert.AreEqual(expectedFileName, fileService.FileNameDeleted); + } + } +} diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs index 807b2dec0e..7cda0da62c 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/Project/VBNetProject.cs @@ -101,17 +101,16 @@ namespace VBNetBinding return base.GetDefaultItemType(fileName); } - public override void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) + public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) { if (this.MinimumSolutionVersion == Solution.SolutionVersionVS2005) { MSBuildEngine.StartBuild(this, - buildServices, options, feedbackSink, MSBuildEngine.AdditionalTargetFiles.Concat( new [] { Path.Combine(MSBuildEngine.SharpDevelopBinPath, "SharpDevelop.CheckMSBuild35Features.targets") })); } else { - base.StartBuild(buildServices, options, feedbackSink); + base.StartBuild(options, feedbackSink); } } diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs index 54112c2b9a..0ceb9d43a0 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/Src/VBNetBracketSearcher.cs @@ -14,7 +14,6 @@ using ICSharpCode.NRefactory; using ICSharpCode.NRefactory.Parser; using ICSharpCode.NRefactory.Parser.VB; using ICSharpCode.SharpDevelop.Editor; -using ICSharpCode.TextEditor.Actions; namespace VBNetBinding { diff --git a/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj b/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj index 1720404192..6d715896d4 100644 --- a/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj +++ b/src/AddIns/BackendBindings/VBNetBinding/Project/VBNetBinding.csproj @@ -79,11 +79,6 @@ - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} NRefactory diff --git a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs index 3ca745594c..0940a5bfa8 100644 --- a/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs +++ b/src/AddIns/BackendBindings/WixBinding/Test/Utils/MockWorkbenchWindow.cs @@ -39,7 +39,7 @@ namespace WixBinding.Tests.Utils } } - public System.Windows.Media.Imaging.BitmapSource Icon { + public System.Windows.Media.ImageSource Icon { get { throw new NotImplementedException(); } diff --git a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs index 2fef80ef74..388199984f 100644 --- a/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs +++ b/src/AddIns/BackendBindings/XamlBinding/XamlBinding/CompletionDataHelper.cs @@ -263,12 +263,15 @@ namespace ICSharpCode.XamlBinding return emptyList; if (lastElement.LocalName.EndsWith(".", StringComparison.OrdinalIgnoreCase) || context.PressedKey == '.') { + if (rt == null) + return list; + string key = string.IsNullOrEmpty(lastElement.Prefix) ? "" : lastElement.Prefix + ":"; - + if (context.ParentElement.LocalName.StartsWith(lastElement.LocalName.TrimEnd('.'), StringComparison.OrdinalIgnoreCase)) { AddAttributes(rt, list, includeEvents); AddAttachedProperties(rt.GetUnderlyingClass(), list, key, lastElement.Name.Trim('.')); - } else if (rt != null && rt.GetUnderlyingClass() != null) + } else AddAttachedProperties(rt.GetUnderlyingClass(), list, key, lastElement.Name.Trim('.')); } else { if (rt == null) { @@ -1283,6 +1286,9 @@ namespace ICSharpCode.XamlBinding public static void AddAttachedProperties(IClass c, List result, string key, string prefix) { + if (c == null) + return; + var attachedProperties = c.Fields.Where(f => f.IsAttached(true, false)); int prefixLength = (prefix.Length > 0) ? prefix.Length + 1 : 0; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj index 967cd4788b..8c8d10176a 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj +++ b/src/AddIns/Debugger/Debugger.AddIn/Debugger.AddIn.csproj @@ -183,14 +183,12 @@ - - @@ -248,15 +246,7 @@ - - - - - - - - diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs index 59578ca350..93bc02e9b7 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/ObjectGraphPad.cs @@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads { // BUG: if pad window is undocked and floats standalone, IsVisible == false (so pad won't refresh) // REQUEST: need to refresh when pad becomes visible -> VisibleChanged event? - if (!this.IsVisible) + if (!objectGraphControl.IsVisible) { return; } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs index 7893dfd990..ffbfefaf63 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Commands/VisualizerDescriptors.cs @@ -31,7 +31,7 @@ namespace Debugger.AddIn.Visualizers public static ReadOnlyCollection GetAllDescriptors() { if (allDescriptors == null) { - allDescriptors = new List(CreateAllDescriptors()).AsReadOnly(); + allDescriptors = CreateAllDescriptors().ToList().AsReadOnly(); } return allDescriptors; } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs deleted file mode 100644 index f37562f41b..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/BoxDotFormatter.cs +++ /dev/null @@ -1,45 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Text; -using System.Windows; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// that treats node as a atomic "box". Edges go from box to box. - /// - public class BoxDotFormatter : DotFormatter - { - public BoxDotFormatter(PositionedGraph posGraph) : base(posGraph) - { - } - - protected override void appendPosNode(PositionedGraphNode node, StringBuilder builder) - { - string nodeName = genId.GetNextId().ToString(); - nodeNames[node] = nodeName; - - Rect neatoInput = transform.NodeToNeatoInput(node); - - string dotFormatNode = - string.Format(this.neatoDoubleFormatter, - "{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\"];", - nodeName, neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height); - builder.AppendLine(dotFormatNode); - } - - protected override void appendPosEdge(PositionedEdge edge, StringBuilder builder) - { - string sourceNodeName = nodeNames[edge.Source.ContainingNode]; - string targetNodeName = nodeNames[edge.Target]; - - builder.AppendLine(string.Format("{0} -> {1}", sourceNodeName, targetNodeName)); - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/DotFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/DotFormatter.cs deleted file mode 100644 index 7c22473b17..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/DotFormatter.cs +++ /dev/null @@ -1,183 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Text; -using System.Linq; -using System.Windows; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// Converts - /// Gets Graphviz's dot format string for wrapped positioned graph. - /// - public string OutputGraphInDotFormat() - { - StringBuilder dotStringBuilder = new StringBuilder(getGraphHeader()); - - foreach (PositionedGraphNode posNode in this.posGraph.Nodes) - { - appendPosNode(posNode, dotStringBuilder); - } - foreach (PositionedEdge posEdge in this.posGraph.Edges) - { - appendPosEdge(posEdge, dotStringBuilder); - } - - dotStringBuilder.AppendLine(getGraphFooter()); - return dotStringBuilder.ToString(); - } - - private bool validateSplinePoints(PositionedEdge edge) - { - // must have correct number of points: one start point and 3 points per bezier segment - return ((edge.SplinePoints.Count - 1) % 3) == 0; - } - - /// - /// Parses edge positions (from Graphviz's plain format) and sets these positions to underlying positioned graph. - /// - /// Graph with positions in Graphviz's plain format - /// with edge positions filled. - public PositionedGraph ParseEdgePositions(string dotGraphString) - { - using (StringReader reader = new System.IO.StringReader(dotGraphString)) - { - skipAfterPattern(reader, "node " + nodeNames[posGraph.Nodes.First()] + " "); - Point neatoFirstNodePos = readPoint(reader); - PositionedGraphNode firstNode = posGraph.Nodes.First(); - Point firstNodePosOur = transform.AsNeato(firstNode.Center); - // determine how Neato shifted the nodes - transform.NeatoShiftX = neatoFirstNodePos.X - firstNodePosOur.X; - transform.NeatoShiftY = neatoFirstNodePos.Y - firstNodePosOur.Y; - - // assume that edges on output are in the same order as posGraph.Edges (!) - foreach (PositionedEdge posEdge in posGraph.Edges) - { - skipAfterPattern(reader, "edge "); - - readWord(reader); // source node name - readWord(reader); // target node name - - int splinePointCount = readInt(reader); - for (int i = 0; i < splinePointCount; i++) - { - Point edgePoint = readPoint(reader); - edgePoint = transform.FromNeatoOutput(edgePoint); - posEdge.SplinePoints.Add(edgePoint); - } - - bool edgeOk = validateSplinePoints(posEdge); - if (!edgeOk) - throw new DebuggerVisualizerException("Parsed edge invalid"); - } - } - // return original graph with filled edge positions - return this.posGraph; - } - - private Point readPoint(TextReader reader) - { - double x = readDouble(reader); - double y = readDouble(reader); - - return new Point(x, y); - } - - private double readDouble(TextReader reader) - { - return double.Parse(readWord(reader), this.neatoDoubleFormatter.DoubleCulture); - } - - private int readInt(TextReader reader) - { - return int.Parse(readWord(reader)); - } - - private string readWord(TextReader reader) - { - StringBuilder word = new StringBuilder(); - int ch = ' '; - while ((ch = reader.Read()) != ' ') - { - if (ch == -1 || ch == '\n' || ch == '\t') - break; - - word.Append((char)ch); - } - return word.ToString(); - } - - private bool skipAfterPattern(StringReader reader, string pattern) - { - int ch = -1; - int pIndex = 0; - int pTarget = pattern.Length; - while ((ch = reader.Read()) != -1) - { - if (ch == pattern[pIndex]) - { - pIndex++; - if (pIndex == pTarget) - return true; - } - else - { - pIndex = 0; - } - } - return false; - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/IdGenerator.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/IdGenerator.cs deleted file mode 100644 index 77eb424c28..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/IdGenerator.cs +++ /dev/null @@ -1,28 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// Generates sequential ids, usefull for node and edge ids. - /// - public class IdGenerator - { - int currentId = 0; - - public IdGenerator() - { - } - - public int GetNextId() - { - return currentId++; - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs deleted file mode 100644 index 01a7064ce2..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoDoubleFormatter.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Globalization; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// When used as IFormatProvider in string.Format, formats doubles to be suitable for Neato. - /// - public class NeatoDoubleFormatter : IFormatProvider, ICustomFormatter - { - private CultureInfo doubleCulture = CultureInfo.GetCultureInfo("en-US"); - /// - /// CultureInfo used for formatting and parsing doubles (en-US). - /// - public CultureInfo DoubleCulture - { - get { return this.doubleCulture; } - } - - public object GetFormat(Type formatType) - { - if (formatType == typeof(ICustomFormatter)) - return this; - else - return null; - } - - public string Format(string format, object arg, IFormatProvider formatProvider) - { - return string.Format(doubleCulture, "{0:0.000}", arg); - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoEdgeRouter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoEdgeRouter.cs deleted file mode 100644 index 7482282a08..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoEdgeRouter.cs +++ /dev/null @@ -1,48 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Text; -using System.Linq; -using System.Windows; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// Given with positions of nodes, calculates positions of edges. - /// - public class NeatoEdgeRouter - { - public NeatoEdgeRouter() - { - } - - /// - /// Given with node positions, calculates edge positions. - /// - /// , the nodes must have positions filled. - /// with preserved node positions and calculated edge positions. - public PositionedGraph CalculateEdges(PositionedGraph graphWithNodesPositioned) - { - DotFormatter dotFormatter = new BoxDotFormatter(graphWithNodesPositioned); - - // convert PosGraph to .dot string - string dotGraphString = dotFormatter.OutputGraphInDotFormat(); - - // pass to neato.exe and wait for output - string dotGraphStringWithPositions = NeatoProcess.Start().CalculatePositions(dotGraphString); - - // parse edge positions from neato's plain output format - PositionedGraph result = dotFormatter.ParseEdgePositions(dotGraphStringWithPositions); - - return result; - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoPositionTransform.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoPositionTransform.cs deleted file mode 100644 index 2bf6fd1efd..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoPositionTransform.cs +++ /dev/null @@ -1,72 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Windows; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// Transforms positions to and from Neato. - /// - public class NeatoPositionTransform - { - private Rect graphBoundingRect; - - // So that Neato works with smaller numbers. Always > 1 - double ourInputScale = 40; - // Neato itself scales input by this constant. Always > 1, 1 for plain output, 72 for .dot output - double neatoOutputScale = 1; - - public NeatoPositionTransform(Rect graphBoundingRectangle) - { - graphBoundingRect = graphBoundingRectangle; - } - - /// - /// X shift, in Neato coords. - /// - public double NeatoShiftX { get; set; } - /// - /// Y shift, in Neato coords. - /// - public double NeatoShiftY { get; set; } - - public Point ToNeatoInput(Point ourPoint) - { - // invert Y axis, as Neato expects this - return new Point(ourPoint.X / ourInputScale, (graphBoundingRect.Bottom - ourPoint.Y) / ourInputScale); - } - - public System.Windows.Point FromNeatoOutput(Point neatoPoint) - { - // Neato multiplies coords by 72 and adds arbitrary shift (which has to be parsed) - double ourX = (neatoPoint.X - NeatoShiftX) / neatoOutputScale * ourInputScale; - double ourYInverted = (neatoPoint.Y - NeatoShiftY) / neatoOutputScale * ourInputScale; - // invert back - our Y axis grows down - return new Point(ourX, graphBoundingRect.Bottom - ourYInverted); - } - - /// - /// Transform points as Neato would transform it if Neato used no shift - /// - /// - /// - public System.Windows.Point AsNeato(Point ourPoint) - { - - return new Point(ourPoint.X * neatoOutputScale / ourInputScale, (graphBoundingRect.Bottom - ourPoint.Y) * neatoOutputScale / ourInputScale); - } - - public Rect NodeToNeatoInput(PositionedGraphNode node) - { - // don't transform size - return new Rect(ToNeatoInput(node.Center), - new Size(node.Width / ourInputScale, node.Height / ourInputScale)); - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoProcess.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoProcess.cs deleted file mode 100644 index d1d750b570..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/NeatoProcess.cs +++ /dev/null @@ -1,104 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.IO; -using System.Text; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// Encapsulates Neato.exe. - /// - public class NeatoProcess - { - private System.Diagnostics.Process neatoProcess; - - /// - /// Starts neato.exe - /// - public static NeatoProcess Start() - { - System.Diagnostics.Process neatoProcess = new System.Diagnostics.Process(); - neatoProcess.StartInfo.FileName = getNeatoExePath(); - neatoProcess.StartInfo.RedirectStandardInput = true; - neatoProcess.StartInfo.RedirectStandardError = true; - neatoProcess.StartInfo.RedirectStandardOutput = true; - neatoProcess.StartInfo.UseShellExecute = false; - neatoProcess.StartInfo.CreateNoWindow = true; - // tell neato to use splines instead of straigt lines - // output type = Graphviz's plain format - neatoProcess.StartInfo.Arguments = " -Gsplines=true -Tplain"; - //p.EnableRaisingEvents = true; - neatoProcess.Exited += delegate { - neatoProcess.Dispose(); - }; - /*p.OutputDataReceived += delegate(object sender, DataReceivedEventArgs e) { - }; - p.ErrorDataReceived += delegate(object sender, DataReceivedEventArgs e) { - };*/ - - neatoProcess.Start(); - - return new NeatoProcess(neatoProcess); - } - - /// Creates new NeatoProcess. - /// Underlying neato.exe process - private NeatoProcess(System.Diagnostics.Process neatoProcess) - { - this.neatoProcess = neatoProcess; - } - - /// Gets directory where Debugger.AddIn.dll resides - private static string getCurrentAssemblyPath() - { - return Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); - } - - private static string getNeatoExePath() - { - return Path.Combine(getCurrentAssemblyPath(), "neato.exe"); - } - - /// - /// Passes given graph to neato and reads output. - /// - /// Graph in Graphviz dot format. - /// Same graph in Graphviz plain format with position information added. - public string CalculatePositions(string dotGraph) - { - // write the input to neato.exe to a file for testing purposes - /*using (var writer = new StreamWriter(Path.Combine(getCurrentAssemblyPath(), "logIn.gv"))) - { - writer.Write(dotGraph); - }*/ - - neatoProcess.StandardInput.Write(dotGraph); - neatoProcess.StandardInput.Flush(); - neatoProcess.StandardInput.Close(); - - StringBuilder output = new StringBuilder(); - while(true) - { - string line = neatoProcess.StandardOutput.ReadLine(); - if (line == null) - { - // happens if neato.exe is killed - throw new DebuggerVisualizerException("Problem getting layout information from neato.exe"); - } - if (line == "stop") - { - break; - } - output.AppendLine(line); - } - - return output.ToString(); - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs deleted file mode 100644 index 0398743608..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/Layout/Tree/RecordDotFormatter.cs +++ /dev/null @@ -1,71 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows; - -namespace Debugger.AddIn.Visualizers.Graph.Layout -{ - /// - /// that treats nodes as records of properties. - /// Edges start at property, end at node. - /// - public class RecordDotFormatter : DotFormatter - { - private Dictionary propertyIds = new Dictionary(); - - public RecordDotFormatter(PositionedGraph posGraph) : base(posGraph) - { - } - - protected override string getGraphHeader() - { - return "digraph G { rankdir=LR; node [shape = record];"; - } - - protected override void appendPosNode(PositionedGraphNode node, StringBuilder builder) - { - string nodeName = genId.GetNextId().ToString(); - nodeNames[node] = nodeName; - - Rect neatoInput = transform.NodeToNeatoInput(node); - - StringBuilder recordLabel = new StringBuilder(); - bool first = true; - foreach (var prop in node.Properties) - { - string propertyId = "f" + genId.GetNextId().ToString(); - propertyIds[prop] = propertyId; - if (!first) - { - recordLabel.Append("|"); - } - recordLabel.Append(string.Format("<{0}> l", propertyId)); - first = false; - } - - string dotFormatNode = - string.Format(this.neatoDoubleFormatter, - "{0} [pos=\"{1},{2}!\" width=\"{3}\" height=\"{4}\" label=\"{5}\"];", - nodeName, - neatoInput.Location.X, neatoInput.Location.Y, neatoInput.Width, neatoInput.Height, - recordLabel.ToString()); - builder.AppendLine(dotFormatNode); - } - - protected override void appendPosEdge(PositionedEdge edge, StringBuilder builder) - { - string sourceNodeName = nodeNames[edge.Source.ContainingNode]; - string sourcePropertyName = propertyIds[edge.Source]; - string targetNodeName = nodeNames[edge.Target]; - - builder.AppendLine(string.Format("{0}:{1} -> {2}", sourceNodeName, sourcePropertyName, targetNodeName)); - } - } -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs index 0734d71ed0..9e4ccffa5b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/NodeControlCache.cs @@ -13,7 +13,7 @@ using System.Linq; namespace Debugger.AddIn.Visualizers.Graph { /// - /// Description of NodeControlCache. + /// Store to reuse s so that they don't have to be created for every drawing. /// public class NodeControlCache { diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs index 26bcc7d56d..14b05bb309 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraph/ObjectGraphProperty.cs @@ -64,7 +64,7 @@ namespace Debugger.AddIn.Visualizers.Graph this.IsAtomic = debuggerVal.Type.IsAtomic(); this.IsNull = debuggerVal.IsNull; - // null and complex properties evaluate to empty string + // null and complex properties will show empty string this.Value = debuggerVal.IsNull || (!this.IsAtomic) ? string.Empty : debuggerVal.InvokeToString(); this.evaluateCalled = true; } diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs index c27bbf2709..3bb8dcb65c 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/ObjectGraphControl.xaml.cs @@ -109,7 +109,7 @@ namespace Debugger.AddIn.Visualizers.Graph this.graphDrawer.ClearCanvas(); return; } - if (debuggerService.IsProcessRunning) // TODO "Process not paused" exception still occurs + if (debuggerService.IsProcessRunning) // "Process not paused" exception still occurs { showErrorMessage("Cannot inspect when the process is running."); return; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/TreeModel/NestedNodeType.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/TreeModel/NestedNodeType.cs deleted file mode 100644 index 1b40ea5eca..0000000000 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/Graph/TreeModel/NestedNodeType.cs +++ /dev/null @@ -1,23 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; - -namespace Debugger.AddIn.Visualizers.Graph -{ - /// - /// Description of NestedNodeType. - /// - /*public enum NestedNodeType - { - ThisNode, - BaseClassNode, - NonPublicInstanceMembersNode, - StaticMembersNode, - NonPublicStaticMembersNode - }*/ -} diff --git a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs index a9ba69de0a..74dfae8fba 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Visualizers/GridVisualizer/ValueProviders/EnumerableValuesProvider.cs @@ -21,7 +21,7 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer /// /// Provides s for debugee objects implementing IEnumerable. /// - public class EnumerableValuesProvider : GridValuesProvider + /*public class EnumerableValuesProvider : GridValuesProvider { public EnumerableValuesProvider(Expression targetObject, DebugType iEnumerableType, DebugType itemType) :base(targetObject, iEnumerableType, itemType) @@ -50,5 +50,5 @@ namespace Debugger.AddIn.Visualizers.GridVisualizer yield return ObjectValue.Create(currentValue, index++, this.memberFromNameMap); } } - } + }*/ } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj index 29ed8bc75d..4f7e7d5935 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/AvalonEdit.AddIn.csproj @@ -146,12 +146,16 @@ + + + SharpDevelopCompletionWindow.cs + {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs index 343f8567ff..8b30bc13ed 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditViewContent.cs @@ -133,6 +133,10 @@ namespace ICSharpCode.AvalonEdit.AddIn codeEditor.PrimaryTextEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(file.FileName)); + if (!file.IsUntitled) { + codeEditor.PrimaryTextEditor.IsReadOnly = (File.GetAttributes(file.FileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly; + } + codeEditor.Load(stream); // we set the file name after loading because this will place the fold markers etc. codeEditor.FileName = FileName.Create(file.FileName); @@ -177,6 +181,10 @@ namespace ICSharpCode.AvalonEdit.AddIn StatusBarService.SetCaretPosition(this.Column, this.Line, this.Column); } + public override bool IsReadOnly { + get { return codeEditor.PrimaryTextEditor.IsReadOnly; } + } + #region Bookmark Handling void BookmarksAttach() { diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs index a9906ae182..e256860267 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CaretReferencesRenderer.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Windows.Threading; +using ICSharpCode.AvalonEdit.AddIn.Options; using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Dom; @@ -26,6 +27,9 @@ namespace ICSharpCode.AvalonEdit.AddIn /// DispatcherTimer delayTimer; const int delayMilliseconds = 800; + /// + /// Delays the Resolve check so that it does not get called too often when user holds an arrow. + /// DispatcherTimer delayMoveTimer; const int delayMoveMilliseconds = 100; @@ -50,11 +54,18 @@ namespace ICSharpCode.AvalonEdit.AddIn this.delayMoveTimer.Tick += TimerMoveTick; this.editorView.TextArea.Caret.PositionChanged += CaretPositionChanged; } + + public void ClearHighlight() + { + this.highlightRenderer.ClearHighlight(); + } void TimerTick(object sender, EventArgs e) { + if (!CodeEditorOptions.Instance.HighlightSymbol) + return; + this.delayTimer.Stop(); - LoggingService.Info("tick"); // almost the same as DebuggerService.HandleToolTipRequest var referencesToBeHighlighted = GetReferencesInCurrentFile(this.lastResolveResult); this.highlightRenderer.SetHighlight(referencesToBeHighlighted); @@ -62,7 +73,9 @@ namespace ICSharpCode.AvalonEdit.AddIn void TimerMoveTick(object sender, EventArgs e) { - LoggingService.Debug("move"); + if (!CodeEditorOptions.Instance.HighlightSymbol) + return; + this.delayMoveTimer.Stop(); this.delayTimer.Stop(); var resolveResult = GetExpressionUnderCaret(); @@ -120,6 +133,13 @@ namespace ICSharpCode.AvalonEdit.AddIn /// bool SameResolveResult(ResolveResult resolveResult, ResolveResult resolveResult2) { + /*if (resolveResult == null && resolveResult2 == null) + return true; + if (resolveResult == null && resolveResult2 != null) + return false; + if (resolveResult != null && resolveResult2 == null) + return false;*/ + // TODO determine if 2 ResolveResults refer to the same symbol return false; } } diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs index 81b3bc977b..05f43f274c 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditor.cs @@ -305,6 +305,8 @@ namespace ICSharpCode.AvalonEdit.AddIn secondaryTextEditor.SetBinding(TextEditor.DocumentProperty, new Binding(TextEditor.DocumentProperty.Name) { Source = primaryTextEditor }); + secondaryTextEditor.SetBinding(TextEditor.IsReadOnlyProperty, + new Binding(TextEditor.IsReadOnlyProperty.Name) { Source = primaryTextEditor }); secondaryTextEditor.SyntaxHighlighting = primaryTextEditor.SyntaxHighlighting; gridSplitter = new GridSplitter { diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs index 671f4ee23a..e02b91f5cd 100755 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/CodeEditorView.cs @@ -72,6 +72,8 @@ namespace ICSharpCode.AvalonEdit.AddIn HighlightBrackets(null, e); else if (e.PropertyName == "EnableFolding") UpdateParseInformation(); + else if (e.PropertyName == "HighlightSymbol") + this.caretReferencesRenderer.ClearHighlight(); } #region CaretPositionChanged - Bracket Highlighting diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs index d96485e379..c046ac1b94 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/CodeEditorOptions.cs @@ -135,6 +135,19 @@ namespace ICSharpCode.AvalonEdit.AddIn.Options } } + bool highlightSymbol = true; + + [DefaultValue(true)] + public bool HighlightSymbol { + get { return highlightSymbol; } + set { + if (highlightSymbol != value) { + highlightSymbol = value; + OnPropertyChanged("HighlightSymbol"); + } + } + } + bool useSmartIndentation = true; [DefaultValue(true)] diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml index 556b22ccec..29c7198180 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/Options/TextViewOptions.xaml @@ -21,6 +21,9 @@ + diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs index c942314f7f..0be18946de 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.cs @@ -11,10 +11,10 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; - using ICSharpCode.AvalonEdit.CodeCompletion; using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; +using ICSharpCode.Core; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Editor; using ICSharpCode.SharpDevelop.Editor.CodeCompletion; @@ -24,7 +24,7 @@ namespace ICSharpCode.AvalonEdit.AddIn /// /// The code completion window. /// - public class SharpDevelopCompletionWindow : CompletionWindow, ICompletionListWindow + public partial class SharpDevelopCompletionWindow : CompletionWindow, ICompletionListWindow { public ICompletionItem SelectedItem { get { @@ -73,7 +73,13 @@ namespace ICSharpCode.AvalonEdit.AddIn throw new ArgumentNullException("editor"); if (itemList == null) throw new ArgumentNullException("itemList"); - this.Style = ICSharpCode.Core.Presentation.GlobalStyles.WindowStyle; + + if (!itemList.ContainsAllAvailableItems) { + // If more items are available (Ctrl+Space wasn't pressed), show this hint + this.EmptyText = StringParser.Parse("${res:ICSharpCode.AvalonEdit.AddIn.SharpDevelopCompletionWindow.EmptyText}"); + } + + InitializeComponent(); this.Editor = editor; this.itemList = itemList; ICompletionItem suggestedItem = itemList.SuggestedItem; @@ -86,6 +92,17 @@ namespace ICSharpCode.AvalonEdit.AddIn this.StartOffset -= itemList.PreselectionLength; } + public static readonly DependencyProperty EmptyTextProperty = + DependencyProperty.Register("EmptyText", typeof(string), typeof(SharpDevelopCompletionWindow), + new FrameworkPropertyMetadata()); + /// + /// The text thats is displayed when the is empty. + /// + public string EmptyText { + get { return (string)GetValue(EmptyTextProperty); } + set { SetValue(EmptyTextProperty, value); } + } + protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.xaml new file mode 100644 index 0000000000..4f70ddee9e --- /dev/null +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/SharpDevelopCompletionWindow.xaml @@ -0,0 +1,33 @@ + + + + + + + \ No newline at end of file diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/StringToVisibilityConverter.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/StringToVisibilityConverter.cs new file mode 100644 index 0000000000..dd52cf2334 --- /dev/null +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/StringToVisibilityConverter.cs @@ -0,0 +1,29 @@ +// +// +// +// +// $Revision: $ +// +using System; +using System.Globalization; +using System.Windows; +using System.Windows.Data; + +namespace ICSharpCode.AvalonEdit.AddIn +{ + [ValueConversion(typeof(string), typeof(Visibility))] + public class StringToVisibilityConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (!(value is string)) + return value == null ? Visibility.Collapsed : Visibility.Visible; + return string.IsNullOrEmpty((string)value) ? Visibility.Collapsed : Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + return null; + } + } +} diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml index 6721aaa770..da1d6020e4 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/themes/generic.xaml @@ -2,6 +2,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:ICSharpCode.AvalonEdit.AddIn" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" + xmlns:core="http://icsharpcode.net/sharpdevelop/core" > - - - - \ No newline at end of file diff --git a/src/AddIns/Misc/HtmlHelp2/Project/Resources/dynamichelp.rc b/src/AddIns/Misc/HtmlHelp2/Project/Resources/dynamichelp.rc deleted file mode 100644 index a700ca66a4..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/Resources/dynamichelp.rc +++ /dev/null @@ -1,10 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// -// HTML RESOURCES -// - -#define RT_HTML 23 - -context RT_HTML "context.html" -open RT_HTML "OpenBook.png" -close RT_HTML "ClosedBook.png" \ No newline at end of file diff --git a/src/AddIns/Misc/HtmlHelp2/Project/Resources/dynamichelp.res b/src/AddIns/Misc/HtmlHelp2/Project/Resources/dynamichelp.res deleted file mode 100644 index 95b3a046e5..0000000000 Binary files a/src/AddIns/Misc/HtmlHelp2/Project/Resources/dynamichelp.res and /dev/null differ diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs deleted file mode 100644 index 397219246b..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/DynamicHelpPad.cs +++ /dev/null @@ -1,635 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Collections.Generic; - using System.Collections.Specialized; - using System.Drawing; - using System.Globalization; - using System.Reflection; - using System.Security.Permissions; - using System.Windows.Forms; - - using HtmlHelp2.Environment; - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; - using ICSharpCode.SharpDevelop.Dom; - using ICSharpCode.SharpDevelop.Gui; - using ICSharpCode.SharpDevelop.Project; - using MSHelpServices; - using ICSharpCode.NRefactory; - using ICSharpCode.SharpDevelop.Editor; - - public class ShowDynamicHelpMenuCommand : AbstractMenuCommand - { - public override void Run() - { - PadDescriptor dynamicHelp = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2DynamicHelpPad)); - if (dynamicHelp != null) dynamicHelp.BringPadToFront(); - } - } - - public class HtmlHelp2DynamicHelpPad : AbstractPadContent - { - HtmlHelp2DynamicHelpBrowserControl dynamicHelpBrowser; - private List dynamicHelpTerms = new List(); - private Location lastPoint = Location.Empty; - private string debugPreElement = String.Empty; - private bool enableDebugInfo = HtmlHelp2Environment.Config.DynamicHelpDebugInfos; - - public override object Control - { - get { return dynamicHelpBrowser; } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public HtmlHelp2DynamicHelpPad() - { - dynamicHelpBrowser = new HtmlHelp2DynamicHelpBrowserControl(); - dynamicHelpBrowser.LoadDynamicHelpPage(); - - ParserService.ParserUpdateStepFinished += UpdateTick; - PropertyPad.SelectedObjectChanged += new EventHandler(this.FormsDesignerSelectedObjectChanged); - PropertyPad.SelectedGridItemChanged += new SelectedGridItemChangedEventHandler(this.FormsDesignerSelectedGridItemChanged); - ProjectService.SolutionClosed += new EventHandler(this.SolutionClosed); - - HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded); - ResourceService.LanguageChanged += delegate { dynamicHelpBrowser.RedrawContent(); }; - } - - #region Dynamic Help Calls - private void BuildDynamicHelpList() - { - try - { - dynamicHelpBrowser.RemoveAllChildren(); - this.debugPreElement = string.Empty; - bool helpResults = false; - Cursor.Current = Cursors.WaitCursor; - - foreach (string currentHelpTerm in this.dynamicHelpTerms) - { - if (!currentHelpTerm.StartsWith("!")) - { - helpResults = (this.CallDynamicHelp(currentHelpTerm, false) || helpResults); - } - } - foreach (string currentHelpTerm in this.dynamicHelpTerms) - { - if (currentHelpTerm.StartsWith("!")) - { - helpResults = (this.CallDynamicHelp(currentHelpTerm.Substring(1)) || helpResults); - } - } - - Cursor.Current = Cursors.Default; - - // debug info - if (this.enableDebugInfo) - { - this.debugPreElement += - string.Format(CultureInfo.InvariantCulture, "
Current project language: {0}", SharpDevLanguage.GetPatchedLanguage()); - dynamicHelpBrowser.CreateDebugPre(this.debugPreElement); - } - } - catch (System.Runtime.InteropServices.COMException ex) - { - LoggingService.Error("Help 2.0: Dynamic Help Call Exception; " + ex.ToString()); - } - } - - private bool CallDynamicHelp(string searchTerm) - { - return this.CallDynamicHelp(searchTerm, true); - } - - private bool CallDynamicHelp(string searchTerm, bool keywordSearch) - { - if (!HtmlHelp2Environment.SessionIsInitialized || HtmlHelp2Environment.DynamicHelpIsBusy) - { - return false; - } - - IHxTopicList topics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchTerm); - bool result = (topics != null && topics.Count > 0); - - if (result) - { - // debug info - this.debugPreElement += - string.Format(CultureInfo.InvariantCulture, - "{0} ({1}): {2} {3}
", searchTerm, (keywordSearch)?"Kwd":"DH", - topics.Count, (topics.Count==1)?"topic":"topics"); - - List newTopics = SortTopics(topics); - foreach (IHxTopic topic in newTopics) - { - if ((keywordSearch)?SharpDevLanguage.CheckUniqueTopicLanguage(topic):SharpDevLanguage.CheckTopicLanguage(topic)) - { - this.BuildNewChild(topic.Location, - topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle, - HxTopicGetTitleDefVal.HxTopicGetTitleFileName), - topic.URL); - } - } - } - return result; - } - - private void BuildNewChild(string sectionName, string topicName, string topicUrl) - { - try { - dynamicHelpBrowser.BuildNewChild(sectionName, topicName, topicUrl); - } catch (NullReferenceException ex) { - // HACK: the code doesn't properly check for nulls, so we just ignore errors. - // There were bug reports with BuildNewChild crashing simply on a layout change. - // e.g. http://community.sharpdevelop.net/forums/t/9180.aspx - LoggingService.Warn(ex); - } - } - #endregion - - #region Taken from DefinitionView.cs - private void UpdateTick(object sender, ParserUpdateStepEventArgs e) - { - WorkbenchSingleton.SafeThreadAsyncCall(UpdateTick, e); - } - - void UpdateTick(ParserUpdateStepEventArgs e) - { - this.dynamicHelpTerms.Clear(); - ResolveResult res = ResolveAtCaret(e); - if (res == null) return; - - if (res != null && res.ResolvedType != null) - { - this.AddToStringCollection(res.ResolvedType.FullyQualifiedName); - } - - MemberResolveResult member = res as MemberResolveResult; - NamespaceResolveResult nspace = res as NamespaceResolveResult; - MethodGroupResolveResult method = res as MethodGroupResolveResult; - TypeResolveResult types = res as TypeResolveResult; - - if (member != null && member.ResolvedMember != null) - { - this.AddToStringCollection(0, member.ResolvedMember.FullyQualifiedName); - } - if (nspace != null) - { - this.AddToStringCollection(0, nspace.Name); - } - if (method != null && method.ContainingType != null) - { - this.AddToStringCollection(0, method.ContainingType.FullyQualifiedName); - } - if (types != null && types.ResolvedClass != null) - { - this.AddToStringCollection(0, types.ResolvedClass.FullyQualifiedName); - } - - BuildDynamicHelpList(); - } - - private ResolveResult ResolveAtCaret(ParserUpdateStepEventArgs e) - { - IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; - if (window == null) return null; - ITextEditorProvider provider = window.ActiveViewContent as ITextEditorProvider; - if (provider == null) return null; - ITextEditor editor = provider.TextEditor; - - // e might be null when this is a manually triggered update - FileName fileName = (e == null) ? editor.FileName : e.FileName; - if (editor.FileName != fileName) return null; - IExpressionFinder expressionFinder = ParserService.GetExpressionFinder(fileName); - if (expressionFinder == null) return null; - string content = (e == null) ? editor.Document.Text : e.Content.Text; - ExpressionResult expr = expressionFinder.FindFullExpression(content, editor.Caret.Offset); - if (expr.Expression == null) return null; - - // save the current position - if(this.lastPoint != null && this.lastPoint == editor.Caret.Position) return null; - this.lastPoint = editor.Caret.Position; - this.AddToStringCollection(string.Format(CultureInfo.InvariantCulture, "!{0}", expr.Expression)); - - return ParserService.Resolve(expr, editor.Caret.Line, editor.Caret.Column, fileName, content); - } - #endregion - - #region Dynamic Help for Forms Designer - private void FormsDesignerSelectedObjectChanged(object sender, EventArgs e) - { - this.CallDynamicHelpForFormsDesigner(PropertyPad.Grid.SelectedObject, - PropertyPad.Grid.SelectedGridItem); - } - - private void FormsDesignerSelectedGridItemChanged(object sender, SelectedGridItemChangedEventArgs e) - { - this.CallDynamicHelpForFormsDesigner(PropertyPad.Grid.SelectedObject, - e.NewSelection); - } - - private void CallDynamicHelpForFormsDesigner(object selectedObject, GridItem selectedItem) - { - if (selectedObject == null) return; - this.dynamicHelpTerms.Clear(); - - Type myObject = selectedObject.GetType(); - if (selectedItem != null && selectedItem.Label != null) { - foreach (Type type in TypeHandling.FindDeclaringType(myObject, selectedItem.Label)) { - this.AddToStringCollection(string.Format(CultureInfo.InvariantCulture, - "{0}.{1}", type.FullName, selectedItem.Label)); - } - } - this.AddToStringCollection(myObject.FullName); - - WorkbenchSingleton.SafeThreadAsyncCall(BuildDynamicHelpList); - } - #endregion - - private void SolutionClosed(object sender, EventArgs e) - { - dynamicHelpBrowser.RemoveAllChildren(); - } - - #region StringCollection & Sorting - private void AddToStringCollection(string searchTerm) - { - this.AddToStringCollection(-1, searchTerm); - } - - private void AddToStringCollection(int insertWhere, string searchTerm) - { - if (this.dynamicHelpTerms.IndexOf(searchTerm) == -1) - { - if (insertWhere == -1) - this.dynamicHelpTerms.Add(searchTerm); - else - this.dynamicHelpTerms.Insert(insertWhere, searchTerm); - } - } - - private static List SortTopics(IHxTopicList topics) - { - if (topics == null || topics.Count == 0) - { - return null; - } - - List result = new List(); - foreach (IHxTopic topic in topics) - { - if (!result.Contains(topic)) result.Add(topic); - } - TopicComparer topicComparer = new TopicComparer(); - result.Sort(topicComparer); - - return result; - } - - class TopicComparer : IComparer - { - public int Compare(IHxTopic x, IHxTopic y) - { - int result = CompareType("kbSyntax", x, y); - if(result == 0) result = CompareType("kbHowTo", x, y); - if(result == 0) result = CompareType("kbOrient", x, y); - if(result == 0) result = CompareType("kbArticle", x, y); - - return result; - } - - private static int CompareType(string topicType, IHxTopic x, IHxTopic y) - { - if(x.HasAttribute("TopicType", topicType) && !y.HasAttribute("TopicType", topicType)) - return -1; - else if(y.HasAttribute("TopicType", topicType) && !x.HasAttribute("TopicType", topicType)) - return 1; - else - return 0; - } - } - #endregion - - private void NamespaceReloaded(object sender, EventArgs e) - { - this.enableDebugInfo = HtmlHelp2Environment.Config.DynamicHelpDebugInfos; - } - } - - public class HtmlHelp2DynamicHelpBrowserControl : UserControl - { - WebBrowser axWebBrowser = new WebBrowser(); - ToolStrip dynamicHelpToolbar = new ToolStrip(); - int internalIndex; - string[] toolbarButtons = new string[] { - "${res:AddIns.HtmlHelp2.Contents}", - "${res:AddIns.HtmlHelp2.Index}", - "${res:AddIns.HtmlHelp2.Search}" - }; - - public void RedrawContent() - { - for (int i = 0; i < toolbarButtons.Length; i++) - { - dynamicHelpToolbar.Items[i].Text = StringParser.Parse(toolbarButtons[i]); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public HtmlHelp2DynamicHelpBrowserControl() - { - this.InitializeComponents(); - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - private void InitializeComponents() - { - Dock = DockStyle.Fill; - Size = new Size(500, 500); - - Controls.Add(axWebBrowser); - axWebBrowser.Dock = DockStyle.Fill; - axWebBrowser.WebBrowserShortcutsEnabled = false; - axWebBrowser.IsWebBrowserContextMenuEnabled = false; - axWebBrowser.AllowWebBrowserDrop = false; - axWebBrowser.DocumentCompleted += - new WebBrowserDocumentCompletedEventHandler(this.OnDocumentCompleted); - - Controls.Add(dynamicHelpToolbar); - dynamicHelpToolbar.Dock = DockStyle.Top; - dynamicHelpToolbar.AllowItemReorder = false; - dynamicHelpToolbar.ShowItemToolTips = false; - dynamicHelpToolbar.GripStyle = ToolStripGripStyle.Hidden; - for (int i = 0; i < toolbarButtons.Length; i++) - { - ToolStripButton button = new ToolStripButton(); - button.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - button.ImageIndex = i; - button.Click += new EventHandler(this.ToolStripButtonClicked); - - dynamicHelpToolbar.Items.Add(button); - } - - this.RedrawContent(); - - dynamicHelpToolbar.ImageList = new ImageList(); - dynamicHelpToolbar.ImageList.ColorDepth = ColorDepth.Depth32Bit; - dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Toc.png")); - dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Index.png")); - dynamicHelpToolbar.ImageList.Images.Add(ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Search.png")); - - if (HtmlHelp2Environment.SessionIsInitialized) - { - HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public void LoadDynamicHelpPage() - { - string url = string.Format(CultureInfo.InvariantCulture, "res://{0}/context", Assembly.GetExecutingAssembly().Location); - axWebBrowser.Navigate(url); - } - - private void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) - { - this.RemoveAllChildren(); - } - - private void ToolStripButtonClicked(object sender, EventArgs e) - { - ToolStripItem item = (ToolStripItem)sender; - PadDescriptor pad = null; - - switch (item.ImageIndex) - { - case 0: - pad = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2TocPad)); - break; - case 1: - pad = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2IndexPad)); - break; - case 2: - pad = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad)); - break; - } - - if(pad != null) pad.BringPadToFront(); - } - - #region Help 2.0 Environment Events - private void NamespaceReloaded(object sender, EventArgs e) - { - this.LoadDynamicHelpPage(); - } - #endregion - - #region WebBrowser Scripting - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public void BuildNewChild(string sectionName, string topicName, string topicLink) - { - HtmlElementCollection children = - axWebBrowser.Document.Body.GetElementsByTagName("span"); - foreach (HtmlElement child in children) - { - if (child.GetAttribute("className") == "section") - { - HtmlElement sectionBlock = child.FirstChild.NextSibling; - HtmlElement contentSpan = sectionBlock.NextSibling.NextSibling; - - if (sectionBlock.TagName == "B" && - sectionBlock.InnerText == sectionName && - contentSpan.TagName == "SPAN" && - contentSpan.GetAttribute("className") == "content") - { - if (!DoesLinkExist(contentSpan, topicName, topicLink)) - { - HtmlElement newLink = this.CreateNewLink(topicLink, topicName); - if (newLink != null) - { - contentSpan.AppendChild(newLink); - contentSpan.AppendChild(this.CreateABreak()); - } - } - - return; - } - } - } - - if (children.Count > 0) - { - axWebBrowser.Document.Body.InsertAdjacentElement - (HtmlElementInsertionOrientation.BeforeEnd, this.CreateABreak()); - } - - HtmlElement linkContent = null; - HtmlElement htmlSection = this.CreateNewSection(sectionName, out linkContent); - if (htmlSection != null) - { - axWebBrowser.Document.Body.InsertAdjacentElement - (HtmlElementInsertionOrientation.BeforeEnd, htmlSection); - - HtmlElement newLink = this.CreateNewLink(topicLink, topicName); - if (newLink != null) - { - linkContent.AppendChild(newLink); - linkContent.AppendChild(this.CreateABreak()); - } - - this.internalIndex++; - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - private HtmlElement CreateNewSection(string sectionName, out HtmlElement linkNode) - { - HtmlElement span = axWebBrowser.Document.CreateElement("span"); - span.SetAttribute("className", "section"); - span.InnerHtml = string.Format - (CultureInfo.InvariantCulture, - "" + - "{1}
", - this.internalIndex, sectionName); - - linkNode = axWebBrowser.Document.CreateElement("span"); - linkNode.SetAttribute("className", "content"); - linkNode.Id = string.Format(CultureInfo.InvariantCulture, "content_{0}", this.internalIndex); - span.AppendChild(linkNode); - - return span; - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - private HtmlElement CreateNewLink(string topicUrl, string topicName) - { - HtmlElement span = axWebBrowser.Document.CreateElement("a"); - span.InnerText = topicName; - span.SetAttribute("src", topicUrl); - span.SetAttribute("className", "link"); - span.SetAttribute("title", topicName); - span.Click += new HtmlElementEventHandler(OnLinkClick); - span.MouseOver += new HtmlElementEventHandler(OnMouseOver); - span.MouseLeave += new HtmlElementEventHandler(OnMouseOut); - - return span; - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - private HtmlElement CreateABreak() - { - HtmlElement br = axWebBrowser.Document.CreateElement("br"); - return br; - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - private static bool DoesLinkExist(HtmlElement parentNode, string topicName, string topicUrl) - { - HtmlElementCollection links = parentNode.GetElementsByTagName("a"); - foreach (HtmlElement link in links) - { - if (string.Compare(topicName, link.InnerText) == 0 && - string.Compare(topicUrl, link.GetAttribute("src")) == 0) - { - return true; - } - } - return false; - } - - private void OnMouseOver(object sender, HtmlElementEventArgs e) - { - HtmlElement link = sender as HtmlElement; - if (link != null) - { - StatusBarService.SetMessage(link.GetAttribute("src")); - } - } - - private void OnMouseOut(object sender, HtmlElementEventArgs e) - { - StatusBarService.SetMessage(string.Empty); - } - - private void OnLinkClick(object sender, HtmlElementEventArgs e) - { - HtmlElement link = sender as HtmlElement; - if (link != null) - { - string url = link.GetAttribute("src"); - if (!string.IsNullOrEmpty(url)) ShowHelpBrowser.OpenHelpView(url); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public void RemoveAllChildren() - { - try - { - this.internalIndex = 0; - var document = axWebBrowser != null ? axWebBrowser.Document : null; - var body = document != null ? document.Body : null; - if (body != null) - body.InnerHtml = string.Empty; - } - catch (System.NotSupportedException ex) - { - LoggingService.Error("Help 2.0: Clean-up Call Exception; " + ex.ToString()); - } - } - #endregion - - #region DebugInfo - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public void CreateDebugPre(string debugInformation) - { - if (!string.IsNullOrEmpty(debugInformation)) - { - axWebBrowser.Document.Body.InsertAdjacentElement - (HtmlElementInsertionOrientation.BeforeEnd, CreateABreak()); - axWebBrowser.Document.Body.InsertAdjacentElement - (HtmlElementInsertionOrientation.BeforeEnd, CreateABreak()); - - HtmlElement pre = axWebBrowser.Document.CreateElement("pre"); - pre.InnerHtml = "--- Dynamic Help Debug ---
" + debugInformation; - - axWebBrowser.Document.Body.InsertAdjacentElement - (HtmlElementInsertionOrientation.BeforeEnd, pre); - } - } - #endregion - } - - public static class TypeHandling - { - public static IEnumerable FindDeclaringType(Type type, string memberName) - { - MemberInfo[] memberInfos = type.GetMember(memberName); - List declaringTypes = new List(); - - foreach (MemberInfo memberInfo in memberInfos) - { - if (!declaringTypes.Contains(memberInfo.DeclaringType)) - declaringTypes.Add(memberInfo.DeclaringType); - } - - foreach (Type declaringType in declaringTypes) - { - yield return declaringType; - } - - #region TypeHandling Class by Robert_G - // QUOTE: "Aber das ist ja wohl eher ein no-Brainer... ;-) - #endregion - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/FavoritesPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/FavoritesPad.cs deleted file mode 100644 index 2793dd2dfd..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/FavoritesPad.cs +++ /dev/null @@ -1,319 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Drawing; - using System.Windows.Forms; - using System.Xml; - - using HtmlHelp2.Environment; - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - - public class ShowFavoritesMenuCommand : AbstractMenuCommand - { - public override void Run() - { - PadDescriptor favorites = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2FavoritesPad)); - if (favorites != null) favorites.BringPadToFront(); - } - } - - public class HtmlHelp2FavoritesPad : AbstractPadContent - { - const string help2FavoritesFile = "help2favorites.xml"; - string[] toolbarButtons = new string[] { - "${res:AddIns.HtmlHelp2.MoveUp}", - "${res:AddIns.HtmlHelp2.MoveDown}", - "${res:AddIns.HtmlHelp2.Rename}", - "${res:AddIns.HtmlHelp2.Delete}" - }; - - bool Help2EnvIsReady = false; - Panel mainPanel = new Panel(); - TreeView tv = new TreeView(); - ToolStrip toolStrip = new ToolStrip(); - - public override Control Control - { - get { return mainPanel; } - } - - public override void RedrawContent() - { - for (int i = 0; i < toolbarButtons.Length; i++) - { - toolStrip.Items[i].ToolTipText = StringParser.Parse(toolbarButtons[i]); - } - } - - public HtmlHelp2FavoritesPad() - { - this.InitializeComponents(); - } - - private void InitializeComponents() - { - Help2EnvIsReady = HtmlHelp2Environment.IsReady; - - mainPanel.Controls.Add(tv); - tv.Dock = DockStyle.Fill; - tv.Enabled = Help2EnvIsReady; - tv.ShowLines = false; - tv.ShowRootLines = false; - tv.LabelEdit = true; - tv.HideSelection = false; - tv.AfterSelect += new TreeViewEventHandler(this.TreeNodeAfterSelect); - tv.BeforeLabelEdit += new NodeLabelEditEventHandler(this.BeforeLabelEdit); - tv.AfterLabelEdit += new NodeLabelEditEventHandler(this.AfterLabelEdit); - tv.KeyDown += new KeyEventHandler(this.TreeViewKeyDown); - tv.DoubleClick += new EventHandler(this.TreeNodeDoubleClick); - - mainPanel.Controls.Add(toolStrip); - toolStrip.Dock = DockStyle.Top; - toolStrip.Enabled = Help2EnvIsReady; - toolStrip.AllowItemReorder = false; - for (int i = 0; i < toolbarButtons.Length; i++) - { - ToolStripButton button = new ToolStripButton(); - button.ToolTipText = StringParser.Parse(toolbarButtons[i]); - button.ImageIndex = i; - button.Enabled = false; - button.Click += new EventHandler(this.ToolStripButtonClicked); - - toolStrip.Items.Add(button); - } - - toolStrip.ImageList = new ImageList(); - toolStrip.ImageList.ColorDepth = ColorDepth.Depth4Bit; - toolStrip.ImageList.TransparentColor = Color.Red; - toolStrip.ImageList.Images.Add(ResourcesHelper.GetBitmap("Favorites.16x16.MoveUp.bmp")); - toolStrip.ImageList.Images.Add(ResourcesHelper.GetBitmap("Favorites.16x16.MoveDown.bmp")); - toolStrip.ImageList.Images.Add(ResourcesHelper.GetBitmap("Favorites.16x16.Rename.bmp")); - toolStrip.ImageList.Images.Add(ResourcesHelper.GetBitmap("Favorites.16x16.Delete.bmp")); - - if (Help2EnvIsReady) this.LoadFavorites(); - } - - #region TreeView - private void TreeNodeAfterSelect(object sender, TreeViewEventArgs e) - { - TreeNode tn = tv.SelectedNode; - - toolStrip.Items[0].Enabled = (tn != null && tn.PrevNode != null); - toolStrip.Items[1].Enabled = (tn != null && tn.NextNode != null); - toolStrip.Items[2].Enabled = (tn != null); - toolStrip.Items[3].Enabled = (tn != null); - } - - private void BeforeLabelEdit(object sender, NodeLabelEditEventArgs e) - { - e.CancelEdit = (e.Node == null); - } - - private void AfterLabelEdit(object Sender, NodeLabelEditEventArgs e) - { - if (e.Label != null && e.Label.Length > 0) - { - if (e.Node.Tag != null && e.Node.Tag is string && (string)e.Node.Tag != "") - { - this.PatchFavoriteName(e.Label.ToString(), (string)e.Node.Tag); - } - } - } - - private void TreeViewKeyDown(object sender, KeyEventArgs e) - { - if (tv.SelectedNode != null) - { - switch (e.KeyCode) - { - case Keys.F2: - tv.SelectedNode.BeginEdit(); - break; - case Keys.Delete: - tv.Nodes.Remove(tv.SelectedNode); - this.SaveFavorites(); - break; - } - } - } - - private void TreeNodeDoubleClick(object sender, EventArgs e) - { - TreeNode tn = tv.SelectedNode; - - if (tn != null && tn.Tag != null && tn.Tag is string && (string)tn.Tag != "") - { - ShowHelpBrowser.OpenHelpView((string)tn.Tag); - } - } - #endregion - - #region ToolStrip - private void ToolStripButtonClicked(object sender, EventArgs e) - { - if (tv.SelectedNode == null) return; - - ToolStripItem item = (ToolStripItem)sender; - TreeNode tempNode = null; - - switch (item.ImageIndex) - { - case 0: - tempNode = (TreeNode)tv.SelectedNode.Clone(); - tv.Nodes.Insert(tv.SelectedNode.PrevNode.Index, tempNode); - tv.Nodes.Remove(tv.SelectedNode); - tv.SelectedNode = tempNode; - this.SaveFavorites(); - break; - case 1: - tempNode = (TreeNode)tv.SelectedNode.Clone(); - TreeNode nextNextNode = tv.SelectedNode.NextNode.NextNode; - if (nextNextNode == null) - tv.Nodes.Add(tempNode); - else - tv.Nodes.Insert(nextNextNode.Index, tempNode); - tv.Nodes.Remove(tv.SelectedNode); - tv.SelectedNode = tempNode; - this.SaveFavorites(); - break; - case 2: - tv.SelectedNode.BeginEdit(); - break; - case 3: - string text = StringParser.Parse("${res:AddIns.HtmlHelp2.RemoveFavorite}", new string[,] {{"0", tv.SelectedNode.Text}}); - DialogResult result = MessageBox.Show(text, - StringParser.Parse("${res:MainWindow.Windows.HelpScoutLabel}"), - MessageBoxButtons.YesNo, - MessageBoxIcon.Question, - MessageBoxDefaultButton.Button2); - if (result == DialogResult.Yes) - { - tv.Nodes.Remove(tv.SelectedNode); - this.SaveFavorites(); - } - break; - } - - this.TreeNodeAfterSelect(null, null); - } - #endregion - - #region Favorites - private void LoadFavorites() - { - tv.Nodes.Clear(); - tv.BeginUpdate(); - - try - { - XmlDocument xmldoc = new XmlDocument(); - xmldoc.Load(PropertyService.ConfigDirectory + help2FavoritesFile); - - XmlNodeList nl = xmldoc.SelectNodes("favorites/favorite"); - for (int i = 0; i < nl.Count; i++) - { - XmlNode title = nl.Item(i).SelectSingleNode("title"); - XmlNode url = nl.Item(i).SelectSingleNode("url"); - - if (title != null && url != null && title.InnerText != "" && url.InnerText != "") - { - TreeNode node = new TreeNode(); - node.Text = title.InnerText; - node.Tag = url.InnerText; - tv.Nodes.Add(node); - } - } - } - catch {} - - tv.EndUpdate(); - } - - private void SaveFavorites() - { - try - { - XmlDocument xmldoc = new XmlDocument(); - xmldoc.LoadXml(""); - - foreach (TreeNode node in tv.Nodes) - { - if (node.Text != "" && node.Tag != null && node.Tag is string && (string)node.Tag != "") - { - XmlNode favorite = xmldoc.CreateElement("favorite"); - - XmlNode title = xmldoc.CreateElement("title"); - title.InnerText = node.Text; - favorite.AppendChild(title); - - XmlCDataSection cdata = xmldoc.CreateCDataSection((string)node.Tag); - XmlNode url = xmldoc.CreateElement("url"); - url.AppendChild(cdata); - favorite.AppendChild(url); - xmldoc.DocumentElement.AppendChild(favorite); - } - } - - xmldoc.Save(PropertyService.ConfigDirectory + help2FavoritesFile); - } - catch {} - } - - private void PatchFavoriteName(string newName, string topicUrl) - { - try - { - XmlDocument xmldoc = new XmlDocument(); - xmldoc.Load(PropertyService.ConfigDirectory + help2FavoritesFile); - - XmlNode node = xmldoc.SelectSingleNode(String.Format("/favorites/favorite[url=\"{0}\"]/title", topicUrl)); - - if (node != null) - { - node.InnerText = newName; - xmldoc.Save(PropertyService.ConfigDirectory + help2FavoritesFile); - } - } - catch {} - } - - public void AddToFavorites(string topicName, string topicUrl) - { - if (Help2EnvIsReady && topicName != "" && topicUrl != "") - { - bool urlFound = false; - - foreach (TreeNode node in tv.Nodes) - { - if (node.Tag != null && - node.Tag is string && - String.Compare(topicUrl, (string)node.Tag) == 0) - { - urlFound = true; - break; - } - } - - if (!urlFound) - { - TreeNode node = new TreeNode(); - node.Text = topicName; - node.Tag = topicUrl; - - tv.Nodes.Add(node); - this.SaveFavorites(); - } - } - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs deleted file mode 100644 index e5c2eeefb2..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexPad.cs +++ /dev/null @@ -1,345 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Drawing; - using System.Security.Permissions; - using System.Windows.Forms; - - using AxMSHelpControls; - using HtmlHelp2.Environment; - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - using MSHelpControls; - using MSHelpServices; - - public class ShowIndexMenuCommand : AbstractMenuCommand - { - public override void Run() - { - PadDescriptor index = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2IndexPad)); - if (index != null) index.BringPadToFront(); - } - } - - public class HtmlHelp2IndexPad : AbstractPadContent - { - MSHelp2IndexControl help2IndexControl; - - public override object Control - { - get { return help2IndexControl; } - } - - public override void Dispose() - { - help2IndexControl.Dispose(); - } - - public HtmlHelp2IndexPad() - { - help2IndexControl = new MSHelp2IndexControl(); - ResourceService.LanguageChanged += delegate { help2IndexControl.RedrawContent(); }; - } - } - - public class MSHelp2IndexControl : UserControl - { - AxHxIndexCtrl indexControl; - ComboBox filterCombobox = new ComboBox(); - ComboBox searchTerm = new ComboBox(); - Label label1 = new Label(); - Label label2 = new Label(); - Label infoLabel = new Label(); - bool indexControlFailed; - bool itemClicked; - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing && indexControl != null) - { - indexControl.Dispose(); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public MSHelp2IndexControl() - { - this.InitializeComponents(); - this.UpdateControls(); - - HtmlHelp2Environment.FilterQueryChanged += new EventHandler(this.FilterQueryChanged); - HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded); - } - - private void UpdateControls() - { - filterCombobox.Enabled = - (HtmlHelp2Environment.SessionIsInitialized && !this.indexControlFailed); - searchTerm.Enabled = - (HtmlHelp2Environment.SessionIsInitialized && !this.indexControlFailed); - infoLabel.Visible = false; - - if (this.indexControlFailed) - { - this.ShowInfoMessage - (StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}")); - } - else if (!HtmlHelp2Environment.SessionIsInitialized) - { - if (indexControl != null) indexControl.Visible = false; - this.ShowInfoMessage - ("${res:AddIns.HtmlHelp2.HelpCollectionMayBeEmpty}"); - } - else - { - indexControl.Visible = true; - this.LoadIndex(); - } - } - - private void InitializeComponents() - { - infoLabel.Dock = DockStyle.Fill; - infoLabel.Visible = false; - infoLabel.TextAlign = ContentAlignment.MiddleCenter; - Controls.Add(infoLabel); - - if (Help2ControlsValidation.IsIndexControlRegistered) - { - try - { - indexControl = new AxHxIndexCtrl(); - indexControl.BeginInit(); - indexControl.Dock = DockStyle.Fill; - indexControl.ItemClick += - new AxMSHelpControls.IHxIndexViewEvents_ItemClickEventHandler(this.IndexItemClick); - indexControl.EndInit(); - Controls.Add(indexControl); - indexControl.CreateControl(); - indexControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle; - indexControl.FontSource = HxFontSourceConstant.HxFontExternal; - } - catch (System.Runtime.InteropServices.COMException ex) - { - LoggingService.Error("Help 2.0: Index control failed; " + ex.ToString()); - this.indexControlFailed = true; - } - } - - Panel panel1 = new Panel(); - Controls.Add(panel1); - panel1.Dock = DockStyle.Top; - panel1.Height = filterCombobox.Height + 7; - - panel1.Controls.Add(filterCombobox); - filterCombobox.Dock = DockStyle.Top; - filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; - filterCombobox.Sorted = true; - filterCombobox.Enabled = false; - filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); - - Controls.Add(label1); - label1.Dock = DockStyle.Top; - label1.TextAlign = ContentAlignment.MiddleLeft; - label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - Panel panel2 = new Panel(); - Controls.Add(panel2); - panel2.Dock = DockStyle.Top; - panel2.Height = searchTerm.Height + 7; - - panel2.Controls.Add(searchTerm); - searchTerm.Dock = DockStyle.Top; - searchTerm.Enabled = false; - searchTerm.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - searchTerm.TextChanged += new EventHandler(this.SearchTextChanged); - searchTerm.KeyPress += new KeyPressEventHandler(this.SearchKeyPress); - - Controls.Add(label2); - label2.Dock = DockStyle.Top; - label2.TextAlign = ContentAlignment.MiddleLeft; - label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - this.RedrawContent(); - - this.indexControlFailed = (this.indexControlFailed || indexControl == null); - } - - private void ShowInfoMessage(string infoText) - { - filterCombobox.Items.Clear(); - searchTerm.Items.Clear(); - searchTerm.Text = string.Empty; - infoLabel.Text = infoText; - infoLabel.Visible = true; - } - - public void RedrawContent() - { - label1.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.FilteredBy}"); - label2.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.LookFor}"); - } - - private void IndexItemClick(object sender, IHxIndexViewEvents_ItemClickEvent e) - { - string indexTerm = indexControl.IndexData.GetFullStringFromSlot(e.iItem, ","); - int indexSlot = e.iItem; - - itemClicked = true; - searchTerm.Items.Insert(0, indexTerm); - searchTerm.SelectedIndex = 0; - itemClicked = false; - - this.ShowSelectedItemEntry(indexTerm, indexSlot); - } - - private void FilterChanged(object sender, EventArgs e) - { - string selectedFilterName = filterCombobox.SelectedItem.ToString(); - if (!string.IsNullOrEmpty(selectedFilterName)) - { - Cursor.Current = Cursors.WaitCursor; - this.SetIndex(selectedFilterName); - Cursor.Current = Cursors.Default; - } - } - - private void SearchTextChanged(object sender, EventArgs e) - { - if (!this.itemClicked && searchTerm.Text.Length > 0) - { - indexControl.Selection = - indexControl.IndexData.GetSlotFromString(searchTerm.Text); - } - } - - private void SearchKeyPress(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)13) - { - int indexSlot = indexControl.IndexData.GetSlotFromString(searchTerm.Text); - string indexTerm = indexControl.IndexData.GetFullStringFromSlot(indexSlot, ","); - - searchTerm.Items.Insert(0, indexTerm); - searchTerm.SelectedIndex = 0; - if (searchTerm.Items.Count > 10) - { - searchTerm.Items.RemoveAt(10); - } - - this.ShowSelectedItemEntry(indexTerm, indexSlot); - } - } - - private void LoadIndex() - { - if (this.SetIndex(HtmlHelp2Environment.CurrentFilterName)) - { - searchTerm.Text = string.Empty; - searchTerm.Items.Clear(); - filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged); - HtmlHelp2Environment.BuildFilterList(filterCombobox); - filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); - } - } - - private bool SetIndex(string filterName) - { - try - { - indexControl.IndexData = - HtmlHelp2Environment.GetIndex(HtmlHelp2Environment.FindFilterQuery(filterName)); - return true; - } - catch (System.Runtime.InteropServices.COMException) - { - LoggingService.Error("Help 2.0: cannot connect to IHxIndex interface (Index)"); - return false; - } - } - - private void ShowSelectedItemEntry(string indexTerm, int indexSlot) - { - PadDescriptor indexResults = - WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2IndexResultsPad)); - if (indexResults == null) return; - - try - { - IHxTopicList matchingTopics = indexControl.IndexData.GetTopicsFromSlot(indexSlot); - - try - { - ((HtmlHelp2IndexResultsPad)indexResults.PadContent).CleanUp(); - ((HtmlHelp2IndexResultsPad)indexResults.PadContent).IndexResultsListView.BeginUpdate(); - - foreach (IHxTopic topic in matchingTopics) - { - ListViewItem lvi = new ListViewItem(); - lvi.Text = - topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle, - HxTopicGetTitleDefVal.HxTopicGetTitleFileName); - lvi.Tag = topic; - lvi.SubItems.Add(topic.Location); - ((HtmlHelp2IndexResultsPad)indexResults.PadContent).IndexResultsListView.Items.Add(lvi); - } - } - finally - { - ((HtmlHelp2IndexResultsPad)indexResults.PadContent).IndexResultsListView.EndUpdate(); - ((HtmlHelp2IndexResultsPad)indexResults.PadContent).SortLV(0); - ((HtmlHelp2IndexResultsPad)indexResults.PadContent).SetStatusMessage(indexTerm); - } - - switch (matchingTopics.Count) - { - case 0: - break; - case 1: - IHxTopic topic = (IHxTopic)matchingTopics.ItemAt(1); - if(topic != null) ShowHelpBrowser.OpenHelpView(topic); - break; - default: - indexResults.BringPadToFront(); - break; - } - } - catch (System.Runtime.InteropServices.COMException cEx) - { - LoggingService.Error("Help 2.0: cannot get matching index entries; " + cEx.ToString()); - } - } - - #region Help 2.0 Environment Events - private void FilterQueryChanged(object sender, EventArgs e) - { - Application.DoEvents(); - - string currentFilterName = filterCombobox.SelectedItem.ToString(); - if (string.Compare(currentFilterName, HtmlHelp2Environment.CurrentFilterName) != 0) - { - filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged); - filterCombobox.SelectedIndex = - filterCombobox.Items.IndexOf(HtmlHelp2Environment.CurrentFilterName); - this.SetIndex(HtmlHelp2Environment.CurrentFilterName); - filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); - } - } - - private void NamespaceReloaded(object sender, EventArgs e) - { - this.UpdateControls(); - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexResultsPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexResultsPad.cs deleted file mode 100644 index 8141438fc0..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/IndexResultsPad.cs +++ /dev/null @@ -1,144 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Collections; - using System.Globalization; - using System.Windows.Forms; - - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - using MSHelpServices; - - public class ShowIndexResultsMenuCommand : AbstractMenuCommand - { - public override void Run() - { - PadDescriptor indexResults = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2IndexResultsPad)); - if (indexResults != null) indexResults.BringPadToFront(); - } - } - - public class HtmlHelp2IndexResultsPad : AbstractPadContent - { - ListView listView = new ListView(); - ColumnHeader title = new ColumnHeader(); - ColumnHeader location = new ColumnHeader(); - - public override object Control - { - get { return listView; } - } - - public ListView IndexResultsListView - { - get { return listView; } - } - - public HtmlHelp2IndexResultsPad() - { - this.SetListViewHeader(); - ResourceService.LanguageChanged += delegate { SetListViewHeader(); }; - - listView.Columns.Add(title); - listView.Columns.Add(location); - - listView.FullRowSelect = true; - listView.Alignment = ListViewAlignment.Left; - listView.View = View.Details; - listView.Dock = DockStyle.Fill; - listView.MultiSelect = false; - listView.HideSelection = false; - listView.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - ListViewResize(this,null); - - listView.Resize += new EventHandler(ListViewResize); - listView.DoubleClick += new EventHandler(ListViewDoubleClick); - listView.ColumnClick += new ColumnClickEventHandler(ColumnClick); - listView.CreateControl(); - } - - public void SortLV(int listViewColumn) - { - listView.ListViewItemSorter = new ListViewItemComparer(listViewColumn); - listView.Sort(); - } - - private void SetListViewHeader() - { - title.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Title}"); - location.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Location}"); - } - - private void ListViewResize(object sender, EventArgs e) - { - int w = (listView.Width - 60) / 2; - title.Width = w; - location.Width = w; - } - - private void ListViewDoubleClick(object sender, EventArgs e) - { - ListViewItem lvi = listView.SelectedItems[0]; - if (lvi != null && lvi.Tag != null && lvi.Tag is IHxTopic) - { - ShowHelpBrowser.OpenHelpView((IHxTopic)lvi.Tag); - } - } - - private void ColumnClick(object sender, ColumnClickEventArgs e) - { - this.SortLV(e.Column); - } - - public void CleanUp() - { - foreach (ListViewItem lvi in listView.Items) - { - if(lvi.Tag != null) { lvi.Tag = null; } - } - - listView.Items.Clear(); - } - - public void SetStatusMessage(string indexTerm) - { - if (listView.Items.Count > 1) - { - string text = StringParser.Parse("${res:AddIns.HtmlHelp2.ResultsOfIndexResults}", - new string[,] - {{"0", indexTerm}, - {"1", listView.Items.Count.ToString(CultureInfo.InvariantCulture)}, - {"2", (listView.Items.Count == 1)?"${res:AddIns.HtmlHelp2.SingleTopic}":"${res:AddIns.HtmlHelp2.MultiTopic}"}} - ); - - StatusBarService.SetMessage(text); - } - } - - #region Sorting - class ListViewItemComparer : IComparer - { - private int col; - - public ListViewItemComparer(int column) - { - col = column; - } - - public int Compare(object x, object y) - { - return String.Compare(((ListViewItem)x).SubItems[col].Text, - ((ListViewItem)y).SubItems[col].Text); - } - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs deleted file mode 100644 index 0c64b7f6da..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchPad.cs +++ /dev/null @@ -1,411 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Drawing; - using System.Globalization; - using System.Windows.Forms; - - using HtmlHelp2.Environment; - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - using ICSharpCode.SharpDevelop.Project; - using ICSharpCode.SharpDevelop.Editor.Search; - using MSHelpServices; - - public class ShowSearchMenuCommand : AbstractMenuCommand - { - public override void Run() - { - PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad)); - if (search != null) - { - search.BringPadToFront(); - ((HtmlHelp2SearchPad)search.PadContent).FocusSearchTextBox(); - } - } - } - - public class HtmlHelp2SearchPad : AbstractPadContent - { - Panel mainPanel = new Panel(); - Button searchButton = new Button(); - ComboBox filterCombobox = new ComboBox(); - ComboBox searchTerm = new ComboBox(); - CheckBox titlesOnly = new CheckBox(); - CheckBox enableStemming = new CheckBox(); - CheckBox reuseMatches = new CheckBox(); - CheckBox hiliteTopics = new CheckBox(); - CheckBox useCurrentLang = new CheckBox(); - Label label1 = new Label(); - Label label2 = new Label(); - bool searchIsBusy; - - public override object Control - { - get { return mainPanel; } - } - - public void FocusSearchTextBox() - { - searchTerm.Focus(); - } - - void RedrawContentInternal() - { - searchButton.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Search}"); - titlesOnly.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.SearchInTitlesOnly}"); - enableStemming.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.LookForSimilarWords}"); - reuseMatches.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.SearchInPreviouslyFoundTopics}"); - hiliteTopics.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HighlightMatches}"); - useCurrentLang.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.UseCurrentProjectLanguageForSearch}"); - label1.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.FilteredBy}"); - label2.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.LookFor}"); - } - - public bool HiliteEnabled - { - get { return hiliteTopics.Checked; } - } - - public HtmlHelp2SearchPad() - { - this.InitializeComponents(); - this.UpdateControls(); - ResourceService.LanguageChanged += delegate { RedrawContentInternal(); }; - - HtmlHelp2Environment.FilterQueryChanged += new EventHandler(FilterQueryChanged); - HtmlHelp2Environment.NamespaceReloaded += new EventHandler(NamespaceReloaded); - - ProjectService.SolutionLoaded += this.SolutionLoaded; - ProjectService.SolutionClosed += this.SolutionUnloaded; - } - - private void UpdateControls() - { - titlesOnly.Enabled = HtmlHelp2Environment.SessionIsInitialized; - enableStemming.Enabled = HtmlHelp2Environment.SessionIsInitialized; - hiliteTopics.Enabled = HtmlHelp2Environment.SessionIsInitialized; - useCurrentLang.Enabled = HtmlHelp2Environment.SessionIsInitialized; - filterCombobox.Enabled = HtmlHelp2Environment.SessionIsInitialized; - searchTerm.Enabled = HtmlHelp2Environment.SessionIsInitialized; - - searchTerm.Text = string.Empty; - searchTerm.Items.Clear(); - filterCombobox.Items.Clear(); - - if (HtmlHelp2Environment.SessionIsInitialized) - { - HtmlHelp2Environment.BuildFilterList(filterCombobox); - } - } - - private void InitializeComponents() - { - // Search controls - Panel panel3 = new Panel(); - mainPanel.Controls.Add(panel3); - panel3.Width = 500; - int pw = panel3.Width; - - panel3.Controls.Add(searchButton); - searchButton.Enabled = false; - searchButton.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - searchButton.Click += new EventHandler(SearchButtonClick); - panel3.Controls.Add(titlesOnly); - panel3.Controls.Add(enableStemming); - panel3.Controls.Add(reuseMatches); - panel3.Controls.Add(hiliteTopics); - panel3.Controls.Add(useCurrentLang); - - titlesOnly.Width = pw; - titlesOnly.Top = searchButton.Top + searchButton.Height + 10; - titlesOnly.TextAlign = ContentAlignment.MiddleLeft; - titlesOnly.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - enableStemming.Width = pw; - enableStemming.Top = titlesOnly.Top + titlesOnly.Height - 4; - enableStemming.TextAlign = ContentAlignment.MiddleLeft; - enableStemming.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - reuseMatches.Width = pw; - reuseMatches.Top = enableStemming.Top + enableStemming.Height - 4; - reuseMatches.Enabled = false; - reuseMatches.TextAlign = ContentAlignment.MiddleLeft; - reuseMatches.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - hiliteTopics.Width = pw; - hiliteTopics.Top = reuseMatches.Top + reuseMatches.Height - 4; - hiliteTopics.TextAlign = ContentAlignment.MiddleLeft; - hiliteTopics.Checked = true; - hiliteTopics.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - useCurrentLang.Width = pw; - useCurrentLang.Top = hiliteTopics.Top + hiliteTopics.Height; - useCurrentLang.TextAlign = ContentAlignment.MiddleLeft; - useCurrentLang.Visible = ProjectService.CurrentProject != null; - useCurrentLang.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - panel3.Dock = DockStyle.Fill; - - // Filter Combobox - Panel panel1 = new Panel(); - mainPanel.Controls.Add(panel1); - panel1.Dock = DockStyle.Top; - panel1.Height = filterCombobox.Height + 15; - panel1.Controls.Add(filterCombobox); - filterCombobox.Dock = DockStyle.Top; - filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; - filterCombobox.Sorted = true; - filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged); - - // Filter label - mainPanel.Controls.Add(label1); - label1.Dock = DockStyle.Top; - label1.TextAlign = ContentAlignment.MiddleLeft; - label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - // SearchTerm Combobox - Panel panel2 = new Panel(); - mainPanel.Controls.Add(panel2); - panel2.Dock = DockStyle.Top; - panel2.Height = searchTerm.Height + 7; - panel2.Controls.Add(searchTerm); - searchTerm.Dock = DockStyle.Top; - searchTerm.TextChanged += new EventHandler(SearchTextChanged); - searchTerm.KeyPress += new KeyPressEventHandler(KeyPressed); - searchTerm.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - mainPanel.Controls.Add(label2); - label2.Dock = DockStyle.Top; - label2.TextAlign = ContentAlignment.MiddleLeft; - label2.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - - this.RedrawContentInternal(); - } - - private void FilterChanged(object sender, EventArgs e) - { - string selectedFilterName = filterCombobox.SelectedItem.ToString(); - if (!string.IsNullOrEmpty(selectedFilterName)) - { - HtmlHelp2Environment.FindFilterQuery(selectedFilterName); - } - } - - #region Help 2.0 Environment Events - private void FilterQueryChanged(object sender, EventArgs e) - { - mainPanel.Refresh(); - - string selectedFilterName = filterCombobox.SelectedItem.ToString(); - if (string.Compare(selectedFilterName, HtmlHelp2Environment.CurrentFilterName) != 0) - { - filterCombobox.SelectedIndexChanged -= new EventHandler(FilterChanged); - filterCombobox.SelectedIndex = filterCombobox.Items.IndexOf(HtmlHelp2Environment.CurrentFilterName); - filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged); - } - } - - private void NamespaceReloaded(object sender, EventArgs e) - { - this.UpdateControls(); - - if (HtmlHelp2Environment.SessionIsInitialized) - { - filterCombobox.SelectedIndexChanged -= new EventHandler(FilterChanged); - HtmlHelp2Environment.BuildFilterList(filterCombobox); - filterCombobox.SelectedIndexChanged += new EventHandler(FilterChanged); - } - } - #endregion - - private void SearchButtonClick(object sender, EventArgs e) - { - if (!string.IsNullOrEmpty(searchTerm.Text)) - { - this.AddTermToList(searchTerm.Text); - this.PerformFts(searchTerm.Text); - } - } - - private void SearchTextChanged(object sender, EventArgs e) - { - searchButton.Enabled = (!string.IsNullOrEmpty(searchTerm.Text)); - } - - private void KeyPressed(object sender, KeyPressEventArgs e) - { - if (e.KeyChar == (char)13 && searchTerm.Text.Length > 0) - { - e.Handled = true; - this.AddTermToList(searchTerm.Text); - this.PerformFts(searchTerm.Text); - } - } - - private void AddTermToList(string searchText) - { - if (searchTerm.Items.IndexOf(searchText) == -1) - { - searchTerm.Items.Insert(0, searchText); - if (searchTerm.Items.Count > 10) searchTerm.Items.RemoveAt(10); - searchTerm.SelectedIndex = 0; - } - } - - #region FTS - private void PerformFts(string searchWord) - { - this.PerformFts(searchWord, false); - } - - private void PerformFts(string searchWord, bool useDynamicHelp) - { - if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(searchWord) || searchIsBusy) - { - return; - } - - HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance; - - HtmlHelp2Dialog searchDialog = new HtmlHelp2Dialog(); - try - { - searchIsBusy = true; - IHxTopicList matchingTopics = null; - - HxQuery_Options searchFlags = HxQuery_Options.HxQuery_No_Option; - searchFlags |= (titlesOnly.Checked)?HxQuery_Options.HxQuery_FullTextSearch_Title_Only:HxQuery_Options.HxQuery_No_Option; - searchFlags |= (enableStemming.Checked)?HxQuery_Options.HxQuery_FullTextSearch_Enable_Stemming:HxQuery_Options.HxQuery_No_Option; - searchFlags |= (reuseMatches.Checked)?HxQuery_Options.HxQuery_FullTextSearch_SearchPrevious:HxQuery_Options.HxQuery_No_Option; - - searchDialog.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSearchCaption}"); - searchDialog.ActionLabel = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSearchInProgress}", - new string[,] - {{"0", searchWord}}); - searchDialog.Show(); - Application.DoEvents(); - Cursor.Current = Cursors.WaitCursor; - if (useDynamicHelp) - matchingTopics = HtmlHelp2Environment.GetMatchingTopicsForDynamicHelp(searchWord); - else - matchingTopics = HtmlHelp2Environment.Fts.Query(searchWord, searchFlags); - - Cursor.Current = Cursors.Default; - - try - { - searchResults.CleanUp(); - searchResults.SearchResultsListView.BeginUpdate(); - - foreach (IHxTopic topic in matchingTopics) - { - if (useCurrentLang.Checked && !useDynamicHelp && !SharpDevLanguage.CheckTopicLanguage(topic)) - continue; - - ListViewItem lvi = new ListViewItem(); - lvi.Text = topic.get_Title(HxTopicGetTitleType.HxTopicGetRLTitle, - HxTopicGetTitleDefVal.HxTopicGetTitleFileName); - lvi.Tag = topic; - lvi.SubItems.Add(topic.Location); - lvi.SubItems.Add(topic.Rank.ToString(CultureInfo.CurrentCulture)); - - searchResults.SearchResultsListView.Items.Add(lvi); - } - - reuseMatches.Enabled = true; - } - finally - { - searchResults.SearchResultsListView.EndUpdate(); - searchResults.SetStatusMessage(searchTerm.Text); - SearchResultsPad.Instance.ShowSearchResults( - new HelpSearchResult(searchTerm.Text, searchResults) - ); - SearchResultsPad.Instance.BringToFront(); - searchIsBusy = false; - } - } - catch (System.Runtime.InteropServices.COMException ex) - { - LoggingService.Error("Help 2.0: cannot get matching search word; " + ex.ToString()); - - foreach (Control control in this.mainPanel.Controls) - { - control.Enabled = false; - } - } - finally - { - searchDialog.Dispose(); - } - } - - public bool PerformF1Fts(string keyword) - { - return this.PerformF1Fts(keyword, false); - } - - public bool PerformF1Fts(string keyword, bool useDynamicHelp) - { - if (!HtmlHelp2Environment.SessionIsInitialized || string.IsNullOrEmpty(keyword) || searchIsBusy) - { - return false; - } - - this.PerformFts(keyword, useDynamicHelp); - - HtmlHelp2SearchResultsView searchResults = HtmlHelp2SearchResultsView.Instance; - return searchResults.SearchResultsListView.Items.Count > 0; - } - #endregion - - #region Project Events to hide/show the new "Use language" checkbox - private void SolutionLoaded(object sender, SolutionEventArgs e) - { - useCurrentLang.Visible = true; - } - - private void SolutionUnloaded(object sender, EventArgs e) - { - useCurrentLang.Visible = false; - useCurrentLang.Checked = false; - } - #endregion - } - - sealed class HelpSearchResult : ISearchResult - { - string searchTerm; - HtmlHelp2SearchResultsView view; - - public HelpSearchResult(string searchTerm, HtmlHelp2SearchResultsView view) - { - this.searchTerm = searchTerm; - this.view = view; - } - - public string Text { - get { return searchTerm; } - } - - public object GetControl() - { - return view; - } - - public System.Collections.IList GetToolbarItems() - { - return null; - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs deleted file mode 100644 index c8d91fbddb..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/SearchResultsPad.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Collections; - using System.Globalization; - using System.Windows.Forms; - - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - using MSHelpServices; - - public class HtmlHelp2SearchResultsView : UserControl - { - ListView listView = new ListView(); - ColumnHeader title = new ColumnHeader(); - ColumnHeader location = new ColumnHeader(); - ColumnHeader rank = new ColumnHeader(); - - static HtmlHelp2SearchResultsView instance; - - public static HtmlHelp2SearchResultsView Instance - { - get - { - if (instance == null) instance = new HtmlHelp2SearchResultsView(); - return instance; - } - } - - public override void Refresh() - { - this.SetListViewHeader(); - base.Refresh(); - } - - public ListView SearchResultsListView - { - get { return listView; } - } - - public HtmlHelp2SearchResultsView() - { - this.SetListViewHeader(); - listView.Columns.Add(title); - listView.Columns.Add(location); - listView.Columns.Add(rank); - - listView.FullRowSelect = true; - listView.AutoArrange = true; - listView.Alignment = ListViewAlignment.Left; - listView.View = View.Details; - listView.Dock = DockStyle.Fill; - listView.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - ListViewResize(this,null); - - listView.Resize += new EventHandler(ListViewResize); - listView.DoubleClick += new EventHandler(ListViewDoubleClick); - listView.ColumnClick += new ColumnClickEventHandler(ColumnClick); - Controls.Add(listView); - } - - private void SetListViewHeader() - { - title.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Title}"); - location.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Location}"); - rank.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.Rank}"); - } - - private void ListViewResize(object sender, EventArgs e) - { - rank.Width = 80; - int w = (listView.Width - rank.Width - 40) / 2; - title.Width = w; - location.Width = w; - } - - private void ListViewDoubleClick(object sender, EventArgs e) - { - PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad)); - bool hiliteMatches = (search != null && ((HtmlHelp2SearchPad)search.PadContent).HiliteEnabled); - - ListViewItem lvi = listView.SelectedItems[0]; - if (lvi != null && lvi.Tag != null && lvi.Tag is IHxTopic) - { - ShowHelpBrowser.OpenHelpView((IHxTopic)lvi.Tag, hiliteMatches); - } - } - - private void ColumnClick(object sender, ColumnClickEventArgs e) - { - listView.ListViewItemSorter = new ListViewItemComparer(e.Column); - listView.Sort(); - } - - public void CleanUp() - { - foreach (ListViewItem lvi in listView.Items) - { - if(lvi.Tag != null) { lvi.Tag = null; } - } - - listView.Items.Clear(); - } - - public void SetStatusMessage(string indexTerm) - { - string text = StringParser.Parse("${res:AddIns.HtmlHelp2.ResultsOfSearchResults}", - new string[,] - {{"0", indexTerm}, - {"1", listView.Items.Count.ToString(CultureInfo.InvariantCulture)}, - {"2", (listView.Items.Count == 1)?"${res:AddIns.HtmlHelp2.SingleTopic}":"${res:AddIns.HtmlHelp2.MultiTopic}"}} - ); - - StatusBarService.SetMessage(text); - } - - #region Sorting - class ListViewItemComparer : IComparer - { - private int col; - - public ListViewItemComparer(int column) - { - col = column; - } - - public int Compare(object x, object y) - { - ListViewItem itemA = x as ListViewItem; - ListViewItem itemB = y as ListViewItem; - - switch (col) - { - case 2: - int a = Int32.Parse(itemA.SubItems[col].Text, CultureInfo.InvariantCulture); - int b = Int32.Parse(itemB.SubItems[col].Text, CultureInfo.InvariantCulture); - if(a > b) return 1; - else if(a < b) return -1; - else return 0; - default: - return string.Compare(itemA.SubItems[col].Text, itemB.SubItems[col].Text); - } - } - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs deleted file mode 100644 index a9c11fc943..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BaseControls/TocPad.cs +++ /dev/null @@ -1,450 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using System.Drawing; - using System.Security.Permissions; - using System.Windows.Forms; - - using AxMSHelpControls; - using HtmlHelp2.Environment; - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - using MSHelpControls; - using PrintOptions = MSHelpServices.HxHierarchy_PrintNode_Options; - using TSC = MSHelpControls.HxTreeStyleConstant; - - public class ShowTocMenuCommand : AbstractMenuCommand - { - public override void Run() - { - PadDescriptor toc = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2TocPad)); - if (toc != null) toc.BringPadToFront(); - } - } - - public class HtmlHelp2TocPad : AbstractPadContent - { - MSHelp2TocControl help2TocControl; - - public override object Control - { - get { return help2TocControl; } - } - - public override void Dispose() - { - help2TocControl.Dispose(); - } - - public HtmlHelp2TocPad() - { - help2TocControl = new MSHelp2TocControl(); - ResourceService.LanguageChanged += delegate { help2TocControl.RedrawContent(); }; - } - - public void SyncToc(string topic) - { - help2TocControl.SynchronizeToc(topic); - } - - public void GetPrevFromNode() - { - help2TocControl.GetPrevFromNode(); - } - - public void GetPrevFromUrl(string topic) - { - help2TocControl.GetPrevFromUrl(topic); - } - - public void GetNextFromNode() - { - help2TocControl.GetNextFromNode(); - } - - public void GetNextFromUrl(string topic) - { - help2TocControl.GetNextFromUrl(topic); - } - - public bool IsNotFirstNode - { - get { return help2TocControl.IsNotFirstNode; } - } - - public bool IsNotLastNode - { - get { return help2TocControl.IsNotLastNode; } - } - } - - public class MSHelp2TocControl : UserControl - { - AxHxTocCtrl tocControl; - ComboBox filterCombobox = new ComboBox(); - Label label1 = new Label(); - Label infoLabel = new Label(); - ContextMenuStrip printContextMenu = new ContextMenuStrip(); - ToolStripMenuItem printTopic = new ToolStripMenuItem(); - ToolStripMenuItem printTopicAndSubTopics = new ToolStripMenuItem(); - bool tocControlFailed; - - protected override void Dispose(bool disposing) - { - base.Dispose(disposing); - if (disposing && tocControl != null) - { - tocControl.Dispose(); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public MSHelp2TocControl() - { - this.InitializeComponents(); - this.UpdateControl(); - - HtmlHelp2Environment.FilterQueryChanged += new EventHandler(this.FilterQueryChanged); - HtmlHelp2Environment.NamespaceReloaded += new EventHandler(this.NamespaceReloaded); - } - - private void UpdateControl() - { - filterCombobox.Enabled = - (HtmlHelp2Environment.SessionIsInitialized && !this.tocControlFailed); - infoLabel.Visible = false; - - if (this.tocControlFailed) - { - this.ShowInfoMessage - (StringParser.Parse("${res:AddIns.HtmlHelp2.HelpSystemNotAvailable}")); - } - else if (!HtmlHelp2Environment.SessionIsInitialized) - { - if (tocControl != null) tocControl.Visible = false; - this.ShowInfoMessage - ("${res:AddIns.HtmlHelp2.HelpCollectionMayBeEmpty}"); - } - else - { - tocControl.Visible = true; - this.LoadToc(); - } - } - - private void InitializeComponents() - { - infoLabel.Dock = DockStyle.Fill; - infoLabel.Visible = false; - infoLabel.TextAlign = ContentAlignment.MiddleCenter; - Controls.Add(infoLabel); - - if (Help2ControlsValidation.IsTocControlRegistered) - { - try - { - tocControl = new AxHxTocCtrl(); - tocControl.BeginInit(); - tocControl.Dock = DockStyle.Fill; - tocControl.NodeClick += - new AxMSHelpControls.IHxTreeViewEvents_NodeClickEventHandler(this.TocNodeClick); - tocControl.NodeRightClick += - new AxMSHelpControls.IHxTreeViewEvents_NodeRightClickEventHandler(TocNodeRightClick); - tocControl.EndInit(); - Controls.Add(tocControl); - tocControl.CreateControl(); - - tocControl.Visible = false; - tocControl.BorderStyle = HxBorderStyle.HxBorderStyle_FixedSingle; - tocControl.FontSource = HxFontSourceConstant.HxFontExternal; - tocControl.TreeStyle = - (HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText; - - printTopic.Image = ResourcesHelper.GetBitmap("HtmlHelp2.16x16.Print.bmp"); - printTopic.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; - printTopic.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.PrintTopic}"); - printTopic.Click += new EventHandler(this.PrintTopic); - printContextMenu.Items.Add(printTopic); - - printTopicAndSubTopics.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.PrintSubtopics}"); - printTopicAndSubTopics.Click += new EventHandler(this.PrintTopicAndSubTopics); - printContextMenu.Items.Add(printTopicAndSubTopics); - } - catch (System.Runtime.InteropServices.COMException cEx) - { - LoggingService.Error("Help 2.0: TOC control failed: " + cEx.ToString()); - this.tocControlFailed = true; - } - } - - Panel panel1 = new Panel(); - Controls.Add(panel1); - panel1.Dock = DockStyle.Top; - panel1.Height = filterCombobox.Height + 7; - - panel1.Controls.Add(filterCombobox); - filterCombobox.Dock = DockStyle.Top; - filterCombobox.DropDownStyle = ComboBoxStyle.DropDownList; - filterCombobox.Sorted = true; - filterCombobox.Enabled = false; - filterCombobox.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); - - Controls.Add(label1); - label1.Dock = DockStyle.Top; - label1.TextAlign = ContentAlignment.MiddleLeft; - label1.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.RedrawContent(); - - this.tocControlFailed = (this.tocControlFailed || tocControl == null); - } - - private void ShowInfoMessage(string infoText) - { - filterCombobox.Items.Clear(); - infoLabel.Text = infoText; - infoLabel.Visible = true; - } - - public void RedrawContent() - { - label1.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.FilteredBy}"); - } - - private void TocNodeClick(object sender, IHxTreeViewEvents_NodeClickEvent e) - { - string topicUrl = tocControl.Hierarchy.GetURL(e.hNode); - this.CallHelp(topicUrl); - } - - private void TocNodeRightClick(object sender, IHxTreeViewEvents_NodeRightClickEvent e) - { - if (e.hNode != 0) - { - printTopic.Enabled = !string.IsNullOrEmpty(tocControl.Hierarchy.GetURL(e.hNode)); - printTopicAndSubTopics.Enabled = tocControl.Hierarchy.GetFirstChild(e.hNode) != 0; - bool selectTextFlag = (tocControl.Hierarchy.GetFirstChild(e.hNode) == 0 || - string.IsNullOrEmpty(tocControl.Hierarchy.GetURL(e.hNode))); - printTopicAndSubTopics.Text = - StringParser.Parse((selectTextFlag)? - "${res:AddIns.HtmlHelp2.PrintSubtopics}": - "${res:AddIns.HtmlHelp2.PrintTopicAndSubtopics}"); - - Point p = new Point(e.x, e.y); - p = this.PointToClient(p); - printContextMenu.Show(this, p); - } - } - - #region Printing - private void PrintTopic(object sender, EventArgs e) - { - if (tocControl.Selection != 0) - { - tocControl.Hierarchy.PrintNode(0, tocControl.Selection, PrintOptions.HxHierarchy_PrintNode_Option_Node); - } - } - - private void PrintTopicAndSubTopics(object sender, EventArgs e) - { - if (tocControl.Selection != 0) - { - tocControl.Hierarchy.PrintNode(0, tocControl.Selection, PrintOptions.HxHierarchy_PrintNode_Option_Children); - } - } - #endregion - - private void FilterChanged(object sender, EventArgs e) - { - string selectedFilterName = filterCombobox.SelectedItem.ToString(); - if (selectedFilterName != null && selectedFilterName.Length > 0) - { - Cursor.Current = Cursors.WaitCursor; - this.SetToc(selectedFilterName); - Cursor.Current = Cursors.Default; - } - } - - private void LoadToc() - { - if (this.SetToc(HtmlHelp2Environment.CurrentFilterName)) - { - filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged); - HtmlHelp2Environment.BuildFilterList(filterCombobox); - filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); - } - } - - private bool SetToc(string filterName) - { - try - { - tocControl.Hierarchy = - HtmlHelp2Environment.GetTocHierarchy(HtmlHelp2Environment.FindFilterQuery(filterName)); - return true; - } - catch (System.Runtime.InteropServices.COMException) - { - LoggingService.Error("Help 2.0: Cannot connect to the IHxHierarchy interface."); - return false; - } - } - - private void CallHelp(string topic) - { - this.CallHelp(topic, true); - } - - private void CallHelp(string topic, bool syncToc) - { - if (!string.IsNullOrEmpty(topic)) - { - if (syncToc) this.SynchronizeToc(topic); - ShowHelpBrowser.OpenHelpView(topic); - } - } - - #region Help 2.0 Environment Events - private void FilterQueryChanged(object sender, EventArgs e) - { - Application.DoEvents(); - - string currentFilterName = filterCombobox.SelectedItem.ToString(); - if (string.Compare(currentFilterName, HtmlHelp2Environment.CurrentFilterName) != 0) - { - filterCombobox.SelectedIndexChanged -= new EventHandler(this.FilterChanged); - filterCombobox.SelectedIndex = - filterCombobox.Items.IndexOf(HtmlHelp2Environment.CurrentFilterName); - this.SetToc(HtmlHelp2Environment.CurrentFilterName); - filterCombobox.SelectedIndexChanged += new EventHandler(this.FilterChanged); - } - } - - private void NamespaceReloaded(object sender, EventArgs e) - { - this.UpdateControl(); - - if (tocControl != null) { - tocControl.TreeStyle = - (HtmlHelp2Environment.Config.TocPictures)?TSC.HxTreeStyle_TreelinesPlusMinusPictureText:TSC.HxTreeStyle_TreelinesPlusMinusText; - } - } - #endregion - - #region Published Help 2.0 Commands - public void SynchronizeToc(string topic) - { - try - { - tocControl.Synchronize(topic); - } - catch (System.Runtime.InteropServices.COMException) - { - // SD2-812: ignore exception when trying to synchronize non-existing URL - } - } - - public void GetNextFromNode() - { - try - { - int currentNode = tocControl.Hierarchy.GetNextFromNode(tocControl.Selection); - string topicUrl = tocControl.Hierarchy.GetURL(currentNode); - this.CallHelp(topicUrl, true); - } - catch (System.Runtime.InteropServices.COMException) - { - } - } - - public void GetNextFromUrl(string topic) - { - if (topic == null || topic.Length == 0) return; - try - { - int currentNode = tocControl.Hierarchy.GetNextFromUrl(topic); - string topicUrl = tocControl.Hierarchy.GetURL(currentNode); - this.CallHelp(topicUrl, true); - } - catch (System.Runtime.InteropServices.COMException) - { - // SD2-812: ignore exception when trying to synchronize non-existing URL - } - catch (ArgumentException) - { - } - } - - public void GetPrevFromNode() - { - try - { - int currentNode = tocControl.Hierarchy.GetPrevFromNode(tocControl.Selection); - string topicUrl = tocControl.Hierarchy.GetURL(currentNode); - this.CallHelp(topicUrl, true); - } - catch (System.Runtime.InteropServices.COMException) - { - } - } - - public void GetPrevFromUrl(string topic) - { - if (topic == null || topic.Length == 0) return; - try - { - int currentNode = tocControl.Hierarchy.GetPrevFromUrl(topic); - string topicUrl = tocControl.Hierarchy.GetURL(currentNode); - this.CallHelp(topicUrl, true); - } - catch (System.Runtime.InteropServices.COMException) - { - // SD2-812: ignore exception when trying to synchronize non-existing URL - } - catch (ArgumentException) - { - } - } - - public bool IsNotFirstNode - { - get - { - try - { - int node = tocControl.Hierarchy.GetPrevFromNode(tocControl.Selection); - return node != 0; - } - catch (System.Runtime.InteropServices.COMException) - { - return true; - } - } - } - - public bool IsNotLastNode - { - get - { - try - { - int node = tocControl.Hierarchy.GetNextFromNode(tocControl.Selection); - return (node != 0); - } - catch (System.Runtime.InteropServices.COMException) - { - return true; - } - } - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/HelpBrowserCommands.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/HelpBrowserCommands.cs deleted file mode 100644 index ba241d1a15..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/HelpBrowserCommands.cs +++ /dev/null @@ -1,88 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Security.Permissions; -using System.Windows.Forms; - -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.BrowserDisplayBinding; -using ICSharpCode.SharpDevelop.Gui; - -namespace HtmlHelp2 -{ - public abstract class HelpToolbarCommand : AbstractCommand - { - public static HtmlHelp2TocPad TocPad - { - get - { - return (HtmlHelp2TocPad)WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2TocPad)).PadContent; - } - } - - public WebBrowser Browser - { - get - { - return ((HtmlViewPane)Owner).WebBrowser; - } - } - - public static void BringTocPadToFront() - { - WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2TocPad)).BringPadToFront(); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - [PermissionSet(SecurityAction.InheritanceDemand, Name="Execution")] - public class SyncTocCommand : HelpToolbarCommand - { - public override void Run() - { - TocPad.SyncToc(Browser.Url.ToString()); - BringTocPadToFront(); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - [PermissionSet(SecurityAction.InheritanceDemand, Name="Execution")] - public class PreviousTopicCommand : HelpToolbarCommand - { - public override void Run() - { - try - { - TocPad.GetPrevFromNode(); - } - catch (System.ArgumentException) - { - TocPad.GetPrevFromUrl(Browser.Url.ToString()); - } - BringTocPadToFront(); - } - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - [PermissionSet(SecurityAction.InheritanceDemand, Name="Execution")] - public class NextTopicCommand : HelpToolbarCommand - { - public override void Run() - { - try - { - TocPad.GetNextFromNode(); - } - catch (System.ArgumentException) - { - TocPad.GetNextFromUrl(Browser.Url.ToString()); - } - BringTocPadToFront(); - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/ShowHelpBrowser.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/ShowHelpBrowser.cs deleted file mode 100644 index f473e6ec55..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserControl/ShowHelpBrowser.cs +++ /dev/null @@ -1,103 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - // With a big "Thank you" to Robert_G (Delphi-PRAXiS) - - using System; - using System.Security.Permissions; - using ICSharpCode.SharpDevelop.BrowserDisplayBinding; - using ICSharpCode.SharpDevelop.Gui; - using MSHelpServices; - - public static class ShowHelpBrowser - { - static bool hiliteMatches; - static IHxTopic lastTopic; - - public static void OpenHelpView(IHxTopic topic) - { - if (topic == null) - { - throw new ArgumentNullException("topic"); - } - OpenHelpView(topic.URL, null, false); - } - - public static void OpenHelpView(IHxTopic topic, bool hiliteMatchingWords) - { - if (topic == null) - { - throw new ArgumentNullException("topic"); - } - OpenHelpView(topic.URL, topic, hiliteMatchingWords); - } - - public static void OpenHelpView(string topicLink) - { - OpenHelpView(topicLink, null, false); - } - - public static void OpenHelpView(string topicLink, bool hiliteMatchingWords) - { - OpenHelpView(topicLink, null, hiliteMatchingWords); - } - - public static void OpenHelpView(string topicLink, IHxTopic topic, bool hiliteMatchingWords) - { - hiliteMatches = hiliteMatchingWords; - lastTopic = topic; - BrowserPane help2Browser = ActiveHelp2BrowserView(); - - if (help2Browser != null) - { - help2Browser.Navigate(topicLink); - help2Browser.WorkbenchWindow.SelectWindow(); - } - } - - public static BrowserPane ActiveHelp2BrowserView() - { - IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow; - if (window != null) - { - BrowserPane browserPane = window.ActiveViewContent as BrowserPane; - if (browserPane != null && browserPane.Url.Scheme == "ms-help") - return browserPane; - } - - foreach(IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) - { - BrowserPane browserPane = view as BrowserPane; - if (browserPane != null && browserPane.Url.Scheme == "ms-help") - return browserPane; - } - return CreateNewHelp2BrowserView(); - } - - public static BrowserPane CreateNewHelp2BrowserView() - { - BrowserPane tempPane = new BrowserPane(); - WorkbenchSingleton.Workbench.ShowView(tempPane); - return tempPane; - } - - [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public static void HighlightDocument(HtmlViewPane htmlViewPane) - { - if (htmlViewPane == null) - { - throw new ArgumentNullException("htmlViewPane"); - } - if (hiliteMatches && lastTopic != null) - { - lastTopic.HighlightDocument(htmlViewPane.WebBrowser.Document.DomDocument); - } - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserScheme.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserScheme.cs deleted file mode 100644 index 1d7acb8dcf..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/BrowserScheme.cs +++ /dev/null @@ -1,91 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -using HtmlHelp2.Environment; -using HtmlHelp2.JScriptGlobals; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop.BrowserDisplayBinding; - -namespace HtmlHelp2 -{ - public class BrowserScheme : DefaultSchemeExtension - { - JScriptExternal scriptObject; - - public override void GoHome(HtmlViewPane pane) - { - if (pane == null) - { - throw new ArgumentNullException("pane"); - } - pane.Navigate(new Uri(HtmlHelp2Environment.DefaultPage)); - } - - public override void GoSearch(HtmlViewPane pane) - { - if (pane == null) - { - throw new ArgumentNullException("pane"); - } - pane.Navigate(new Uri(HtmlHelp2Environment.SearchPage)); - } - -// [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public override void InterceptNavigate(HtmlViewPane pane, WebBrowserNavigatingEventArgs e) - { - if (pane == null) - { - throw new ArgumentNullException("pane"); - } - if (scriptObject == null) { - scriptObject = new JScriptExternal(); - LoadHelpState(); - } - pane.WebBrowser.ObjectForScripting = scriptObject; - // add event (max. 1 one time) - pane.WebBrowser.Disposed -= SaveHelpState; - pane.WebBrowser.Disposed += SaveHelpState; - base.InterceptNavigate(pane, e); - } - - void LoadHelpState() - { - foreach (string line in PropertyService.Get("HtmlHelpPersistedJScriptGlobals", new string[0])) { - int pos = line.IndexOf('='); - string name = line.Substring(0, pos); - scriptObject.Globals.VariablePersistCollection[name] = true; - scriptObject.Globals.VariableValueCollection[name] = line.Substring(pos + 1); - } - } - - void SaveHelpState(object sender, EventArgs e) - { - ((System.ComponentModel.IComponent)sender).Disposed -= SaveHelpState; - List lines = new List(); - foreach (KeyValuePair pair in scriptObject.Globals.VariablePersistCollection) { - if (pair.Value) { - lines.Add(pair.Key + "=" + scriptObject.Globals.VariableValueCollection[pair.Key]); - } - } - PropertyService.Set("HtmlHelpPersistedJScriptGlobals", lines.ToArray()); - } - -// [PermissionSet(SecurityAction.LinkDemand, Name="Execution")] - public override void DocumentCompleted(HtmlViewPane pane, WebBrowserDocumentCompletedEventArgs e) - { - if (pane == null) - { - throw new ArgumentNullException("pane"); - } - ShowHelpBrowser.HighlightDocument(pane); - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs deleted file mode 100644 index 822b35e20e..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Commands/ShowErrorHelpCommand.cs +++ /dev/null @@ -1,85 +0,0 @@ -// -// -// -// -// $Revision$ -// - -using MSHelpServices; -using System; -using System.Collections.Generic; -using System.Windows.Forms; -using ICSharpCode.Core; -using ICSharpCode.SharpDevelop; -using ICSharpCode.SharpDevelop.Gui; - -namespace HtmlHelp2.Commands -{ - /// - /// Shows help information for an error in the Errors window. - /// - public class ShowErrorHelpCommand : AbstractMenuCommand - { - /// - /// Starts the command - /// - public override void Run() - { - ICSharpCode.SharpDevelop.Gui.TaskView view = (ICSharpCode.SharpDevelop.Gui.TaskView)Owner; - - // Search all selected tasks - foreach (Task t in new List(view.SelectedTasks)) { - if (t.BuildError == null) - continue; - - string code = t.BuildError.ErrorCode; - - if (string.IsNullOrEmpty(code)) - return; - - // Get help content - MSHelpServices.IHxTopic topic; - - // If HtmlHelp2 AddIn is initialised correctly we can start! - if (HtmlHelp2.Environment.HtmlHelp2Environment.SessionIsInitialized) { - // Get the topic - IHxIndex index = HtmlHelp2.Environment.HtmlHelp2Environment.GetIndex(""); - if (index == null) { - MessageService.ShowErrorFormatted("No help available for {0}!", code); - return; - } - int indexSlot = index.GetSlotFromString(code); - if (indexSlot <= 0) { - MessageService.ShowErrorFormatted("No help available for {0}!", code); - return; - } - IHxTopicList list = index.GetTopicsFromSlot(indexSlot); - if (list == null) { - MessageService.ShowErrorFormatted("No help available for {0}!", code); - return; - } - try { - topic = list.ItemAt(1); - } catch (ArgumentException) { - topic = null; - } - if (topic == null) { - MessageService.ShowErrorFormatted("No help available for {0}!", code); - return; - } - string topicTitle = topic.get_Title(HxTopicGetTitleType.HxTopicGetTOCTitle, HxTopicGetTitleDefVal.HxTopicGetTitleFileName); - if (topicTitle == null || !topicTitle.Contains(code)) { - MessageService.ShowErrorFormatted("No help available for {0}!", code); - return; - } - } else { // Otherwise we have to show an Error message ... - LoggingService.Error("Couldn't initialize help database"); - return; - } - - // Show Browser window - HtmlHelp2.ShowHelpBrowser.OpenHelpView(topic); - } - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs deleted file mode 100644 index 9755c665f9..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/MsHelpProvider.cs +++ /dev/null @@ -1,47 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2 -{ - using System; - using ICSharpCode.Core; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Gui; - - public class MSHelpProvider : HelpProvider - { - public override bool TryShowHelp(string fullTypeName) - { - LoggingService.Info("Help 2.0: MsHelpProvider.TryShowHelp"); - -// try -// { - PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad)); - return ((HtmlHelp2SearchPad)search.PadContent).PerformF1Fts(fullTypeName, true); -// } -// catch -// { -// return false; -// } - } - - public override bool TryShowHelpByKeyword(string keyword) - { - LoggingService.Info("Help 2.0: MsHelpProvider.TryShowHelpByKeyword"); - -// try -// { - PadDescriptor search = WorkbenchSingleton.Workbench.GetPad(typeof(HtmlHelp2SearchPad)); - return ((HtmlHelp2SearchPad)search.PadContent).PerformF1Fts(keyword); -// } -// catch -// { -// return false; -// } - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/AxMSHelpControls.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/AxMSHelpControls.cs deleted file mode 100644 index 8cb693d075..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/AxMSHelpControls.cs +++ /dev/null @@ -1,764 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50215.44 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ -namespace AxMSHelpControls -{ - [System.Windows.Forms.AxHost.ClsidAttribute("{314111b8-a502-11d2-bbca-00c04f8ec294}")] - [System.ComponentModel.DesignTimeVisibleAttribute(true)] - public class AxHxTocCtrl : System.Windows.Forms.AxHost { - - private MSHelpControls.IHxTreeView ocx; - - private AxHxTocCtrlEventMulticaster eventMulticaster; - - private System.Windows.Forms.AxHost.ConnectionPointCookie cookie; - - public AxHxTocCtrl() : base("314111b8-a502-11d2-bbca-00c04f8ec294") - { - } - - [System.ComponentModel.Browsable(false)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4096)] - public virtual MSHelpServices.IHxHierarchy Hierarchy { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Hierarchy", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Hierarchy; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Hierarchy", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Hierarchy = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4100)] - public virtual int ImageList { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("ImageList", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.ImageList; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("ImageList", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.ImageList = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4097)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual bool HideSelection { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HideSelection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.HideSelection; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HideSelection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.HideSelection = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4098)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxTreeLineStyleConstant LineStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LineStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.LineStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LineStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.LineStyle = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4099)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxTreeStyleConstant TreeStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("TreeStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.TreeStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("TreeStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.TreeStyle = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-501)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Color BackColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.BackColor))); - } - else { - return base.BackColor; - } - } - set { - base.BackColor = value; - if ((this.ocx != null)) { - this.ocx.BackColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-513)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Color ForeColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.ForeColor))); - } - else { - return base.ForeColor; - } - } - set { - base.ForeColor = value; - if ((this.ocx != null)) { - this.ocx.ForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-504)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxBorderStyle BorderStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.BorderStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.BorderStyle = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-520)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxAppearanceConstant Appearance { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Appearance; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Appearance = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-521)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxMousePointerConstant MousePointer { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.MousePointer; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.MousePointer = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-512)] - [System.Runtime.InteropServices.ComAliasNameAttribute("stdole.StdFont")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Font Font { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetFontFromIFont(this.ocx.Font); - } - else { - return base.Font; - } - } - set { - base.Font = value; - if ((this.ocx != null)) { - this.ocx.Font = ((stdole.StdFont)(GetIFontFromFont(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4102)] - public virtual int Selection { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Selection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Selection; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4103)] - public virtual short LangId { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.LangId; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.LangId = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4104)] - public virtual MSHelpControls.HxFontSourceConstant FontSource { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.FontSource; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FontSource = value; - } - } - - public event IHxTreeViewEvents_NodeClickEventHandler NodeClick; - - public event IHxTreeViewEvents_NodeRightClickEventHandler NodeRightClick; - - public override void Refresh() { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Refresh", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.Refresh(); - } - - public virtual void Synchronize(string bstrURL) { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Synchronize", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.Synchronize(bstrURL); - } - - protected override void CreateSink() { - try { - this.eventMulticaster = new AxHxTocCtrlEventMulticaster(this); - this.cookie = new System.Windows.Forms.AxHost.ConnectionPointCookie(this.ocx, this.eventMulticaster, typeof(MSHelpControls.IHxTreeViewEvents)); - } - catch (System.Exception ) { - } - } - - protected override void DetachSink() { - try { - this.cookie.Disconnect(); - } - catch (System.Exception ) { - } - } - - protected override void AttachInterfaces() { - try { - this.ocx = ((MSHelpControls.IHxTreeView)(this.GetOcx())); - } - catch (System.Exception ) { - } - } - - internal void RaiseOnNodeClick(object sender, IHxTreeViewEvents_NodeClickEvent e) { - if ((this.NodeClick != null)) { - this.NodeClick(sender, e); - } - } - - internal void RaiseOnNodeRightClick(object sender, IHxTreeViewEvents_NodeRightClickEvent e) { - if ((this.NodeRightClick != null)) { - this.NodeRightClick(sender, e); - } - } - } - - public delegate void IHxTreeViewEvents_NodeClickEventHandler(object sender, IHxTreeViewEvents_NodeClickEvent e); - - public class IHxTreeViewEvents_NodeClickEvent { - - public int hNode; - - public IHxTreeViewEvents_NodeClickEvent(int hNode) { - this.hNode = hNode; - } - } - - public delegate void IHxTreeViewEvents_NodeRightClickEventHandler(object sender, IHxTreeViewEvents_NodeRightClickEvent e); - - public class IHxTreeViewEvents_NodeRightClickEvent { - - public int hNode; - - public int x; - - public int y; - - public IHxTreeViewEvents_NodeRightClickEvent(int hNode, int x, int y) { - this.hNode = hNode; - this.x = x; - this.y = y; - } - } - - [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)] - public class AxHxTocCtrlEventMulticaster : MSHelpControls.IHxTreeViewEvents { - - private AxHxTocCtrl parent; - - public AxHxTocCtrlEventMulticaster(AxHxTocCtrl parent) { - this.parent = parent; - } - - public virtual void NodeClick(int hNode) { - IHxTreeViewEvents_NodeClickEvent nodeclickEvent = new IHxTreeViewEvents_NodeClickEvent(hNode); - this.parent.RaiseOnNodeClick(this.parent, nodeclickEvent); - } - - public virtual void NodeRightClick(int hNode, int x, int y) { - IHxTreeViewEvents_NodeRightClickEvent noderightclickEvent = new IHxTreeViewEvents_NodeRightClickEvent(hNode, x, y); - this.parent.RaiseOnNodeRightClick(this.parent, noderightclickEvent); - } - } - - [System.Windows.Forms.AxHost.ClsidAttribute("{314111c6-a502-11d2-bbca-00c04f8ec294}")] - [System.ComponentModel.DesignTimeVisibleAttribute(true)] - public class AxHxIndexCtrl : System.Windows.Forms.AxHost { - - private MSHelpControls.IHxIndexView ocx; - - private AxHxIndexCtrlEventMulticaster eventMulticaster; - - private System.Windows.Forms.AxHost.ConnectionPointCookie cookie; - - public AxHxIndexCtrl() : - base("314111c6-a502-11d2-bbca-00c04f8ec294") { - } - - [System.ComponentModel.Browsable(false)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16384)] - public virtual MSHelpServices.IHxIndex IndexData { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("IndexData", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.IndexData; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("IndexData", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.IndexData = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16385)] - public virtual int Selection { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Selection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Selection; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Selection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Selection = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-501)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public override System.Drawing.Color BackColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.BackColor))); - } - else { - return base.BackColor; - } - } - set { - base.BackColor = value; - if ((this.ocx != null)) { - this.ocx.BackColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-513)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public override System.Drawing.Color ForeColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.ForeColor))); - } - else { - return base.ForeColor; - } - } - set { - base.ForeColor = value; - if ((this.ocx != null)) { - this.ocx.ForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-504)] - public virtual MSHelpControls.HxBorderStyle BorderStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.BorderStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.BorderStyle = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-520)] - public virtual MSHelpControls.HxAppearanceConstant Appearance { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Appearance; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Appearance = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-521)] - public virtual MSHelpControls.HxMousePointerConstant MousePointer { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.MousePointer; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.MousePointer = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-512)] - [System.Runtime.InteropServices.ComAliasNameAttribute("stdole.StdFont")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Font Font { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetFontFromIFont(this.ocx.Font); - } - else { - return base.Font; - } - } - set { - base.Font = value; - if ((this.ocx != null)) { - this.ocx.Font = ((stdole.StdFont)(GetIFontFromFont(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16388)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color HighlightForeColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.HighlightForeColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.HighlightForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16389)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color HighlightBackColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.HighlightBackColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.HighlightBackColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16390)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color FocusHighlightForeColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.FocusHighlightForeColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FocusHighlightForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16391)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color FocusHighlightBackColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.FocusHighlightBackColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FocusHighlightBackColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16392)] - public virtual short LangId { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.LangId; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.LangId = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16393)] - public virtual MSHelpControls.HxFontSourceConstant FontSource { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.FontSource; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FontSource = value; - } - } - - public event IHxIndexViewEvents_ItemClickEventHandler ItemClick; - - public event IHxIndexViewEvents_ItemSelectEventHandler ItemSelect; - - public virtual void SelectItem(int iItem) { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("SelectItem", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.SelectItem(iItem); - } - - public virtual void ClickItem(int iItem) { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("ClickItem", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.ClickItem(iItem); - } - - public override void Refresh() { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Refresh", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.Refresh(); - } - - protected override void CreateSink() { - try { - this.eventMulticaster = new AxHxIndexCtrlEventMulticaster(this); - this.cookie = new System.Windows.Forms.AxHost.ConnectionPointCookie(this.ocx, this.eventMulticaster, typeof(MSHelpControls.IHxIndexViewEvents)); - } - catch (System.Exception ) { - } - } - - protected override void DetachSink() { - try { - this.cookie.Disconnect(); - } - catch (System.Exception ) { - } - } - - protected override void AttachInterfaces() { - try { - this.ocx = ((MSHelpControls.IHxIndexView)(this.GetOcx())); - } - catch (System.Exception ) { - } - } - - internal void RaiseOnItemClick(object sender, IHxIndexViewEvents_ItemClickEvent e) { - if ((this.ItemClick != null)) { - this.ItemClick(sender, e); - } - } - - internal void RaiseOnItemSelect(object sender, IHxIndexViewEvents_ItemSelectEvent e) { - if ((this.ItemSelect != null)) { - this.ItemSelect(sender, e); - } - } - } - - public delegate void IHxIndexViewEvents_ItemClickEventHandler(object sender, IHxIndexViewEvents_ItemClickEvent e); - - public class IHxIndexViewEvents_ItemClickEvent { - - public int iItem; - - public IHxIndexViewEvents_ItemClickEvent(int iItem) { - this.iItem = iItem; - } - } - - public delegate void IHxIndexViewEvents_ItemSelectEventHandler(object sender, IHxIndexViewEvents_ItemSelectEvent e); - - public class IHxIndexViewEvents_ItemSelectEvent { - - public int iItem; - - public IHxIndexViewEvents_ItemSelectEvent(int iItem) { - this.iItem = iItem; - } - } - - [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)] - public class AxHxIndexCtrlEventMulticaster : MSHelpControls.IHxIndexViewEvents { - - private AxHxIndexCtrl parent; - - public AxHxIndexCtrlEventMulticaster(AxHxIndexCtrl parent) { - this.parent = parent; - } - - public virtual void ItemClick(int iItem) { - IHxIndexViewEvents_ItemClickEvent itemclickEvent = new IHxIndexViewEvents_ItemClickEvent(iItem); - this.parent.RaiseOnItemClick(this.parent, itemclickEvent); - } - - public virtual void ItemSelect(int iItem) { - IHxIndexViewEvents_ItemSelectEvent itemselectEvent = new IHxIndexViewEvents_ItemSelectEvent(iItem); - this.parent.RaiseOnItemSelect(this.parent, itemselectEvent); - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs deleted file mode 100644 index 04c27ed8d8..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2ControlsValidation.cs +++ /dev/null @@ -1,52 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using System; - using System.IO; - using Microsoft.Win32; - - public sealed class Help2ControlsValidation - { - Help2ControlsValidation() - { - } - - public static bool IsTocControlRegistered - { - get - { - return IsClassRegistered("{314111b8-a502-11d2-bbca-00c04f8ec294}"); - } - } - - public static bool IsIndexControlRegistered - { - get - { - return IsClassRegistered("{314111c6-a502-11d2-bbca-00c04f8ec294}"); - } - } - - private static bool IsClassRegistered(string classId) - { - try - { - RegistryKey tmp = Registry.ClassesRoot.OpenSubKey - (string.Format(null, @"CLSID\{0}\InprocServer32", classId), false); - string help2Library = (string)tmp.GetValue("", string.Empty); - tmp.Close(); - return (!string.IsNullOrEmpty(help2Library) && File.Exists(help2Library)); - } - catch (System.NullReferenceException) - { - } - return false; - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs deleted file mode 100644 index e93c0083cd..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/Help2RegistryWalker.cs +++ /dev/null @@ -1,180 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using System; - using System.Runtime.InteropServices; - using System.Windows.Forms; - - using MSHelpServices; - - public sealed class Help2RegistryWalker - { - Help2RegistryWalker() - { - } - - public static bool BuildNamespacesList(ComboBox help2Collections, string selectedHelp2Collection) - { - if (help2Collections == null) - { - throw new ArgumentNullException("help2Collections"); - } - - HxRegistryWalkerClass registryWalker; - IHxRegNamespaceList help2Namespaces; - try - { - registryWalker = new HxRegistryWalkerClass(); - help2Namespaces = registryWalker.get_RegisteredNamespaceList(""); - } - catch (System.Runtime.InteropServices.COMException) - { - help2Namespaces = null; - registryWalker = null; - } - - if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0) - { - return false; - } - - help2Collections.Items.Clear(); - help2Collections.BeginUpdate(); - try - { - string currentDescription = string.Empty; - - foreach (IHxRegNamespace currentNamespace in help2Namespaces) - { - help2Collections.Items.Add - ((string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription)); - - if (!string.IsNullOrEmpty(selectedHelp2Collection) && - string.Compare(selectedHelp2Collection, currentNamespace.Name) == 0) - { - currentDescription = - (string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription); - } - } - - if (!string.IsNullOrEmpty(currentDescription)) - help2Collections.SelectedIndex = help2Collections.Items.IndexOf(currentDescription); - else - help2Collections.SelectedIndex = 0; - } - finally - { - help2Collections.EndUpdate(); - } - return true; - } - - public static string GetNamespaceName(string description) - { - HxRegistryWalkerClass registryWalker; - IHxRegNamespaceList help2Namespaces; - try - { - registryWalker = new HxRegistryWalkerClass(); - help2Namespaces = registryWalker.get_RegisteredNamespaceList(""); - } - catch (System.Runtime.InteropServices.COMException) - { - help2Namespaces = null; - registryWalker = null; - } - - if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0) - { - return string.Empty; - } - foreach (IHxRegNamespace currentNamespace in help2Namespaces) - { - string currentDescription = - (string)currentNamespace.GetProperty(HxRegNamespacePropId.HxRegNamespaceDescription); - if (string.Compare(currentDescription, description) == 0) - { - return currentNamespace.Name; - } - } - return string.Empty; - } - - public static string GetFirstNamespace(string name) - { - HxRegistryWalkerClass registryWalker; - IHxRegNamespaceList help2Namespaces; - try - { - registryWalker = new HxRegistryWalkerClass(); - help2Namespaces = registryWalker.get_RegisteredNamespaceList(""); - } - catch (System.Runtime.InteropServices.COMException) - { - help2Namespaces = null; - registryWalker = null; - } - - if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0) - { - return string.Empty; - } - foreach (IHxRegNamespace currentNamespace in help2Namespaces) - { - if (string.Compare(currentNamespace.Name, name) == 0) - { - return name; - } - } - return help2Namespaces.ItemAt(1).Name; - } - - public static string GetFirstMatchingNamespaceName(string matchingName) - { - HxRegistryWalkerClass registryWalker; - IHxRegNamespaceList help2Namespaces; - try - { - registryWalker = new HxRegistryWalkerClass(); - help2Namespaces = registryWalker.get_RegisteredNamespaceList(""); - - if (registryWalker == null || help2Namespaces == null || help2Namespaces.Count == 0 || string.IsNullOrEmpty(matchingName)) - { - return string.Empty; - } - foreach (IHxRegNamespace currentNamespace in help2Namespaces) - { - if (NativeMethods.PathMatchSpec(currentNamespace.Name, matchingName)) - { - return currentNamespace.Name; - } - } - return help2Namespaces.ItemAt(1).Name; - } - catch (System.Runtime.InteropServices.COMException) - { - return string.Empty; - } - } - - } - - internal class NativeMethods - { - NativeMethods() - { - } - - #region PatchMatchSpec - [DllImport("shlwapi.dll")] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool PathMatchSpec(string pwszFile, string pwszSpec); - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Dialog.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Dialog.cs deleted file mode 100644 index b0e7a15f3b..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Dialog.cs +++ /dev/null @@ -1,123 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using System; - using System.Drawing; - using System.Windows.Forms; - - public class IconPictureBox : PictureBox - { - private Icon icon; - - public Icon Icon - { - get - { - return this.icon; - } - set - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - else - { - this.icon = value; - base.Image = this.icon.ToBitmap(); - } - } - } - - protected override void OnPaint(PaintEventArgs e) - { - e.Graphics.DrawIconUnstretched(this.icon, base.ClientRectangle); - } - } - - public class HtmlHelp2Dialog : Form - { - private IconPictureBox pictureBox1; - private System.Windows.Forms.Label actionLabel; - - public string ActionLabel - { - get { return actionLabel.Text; } - set { actionLabel.Text = value; } - } - - public Icon ActionIcon - { - get { return pictureBox1.Icon; } - set - { - if (value == null) - { - throw new ArgumentNullException("value"); - } - else - { - pictureBox1.Icon = value; - } - } - } - - public HtmlHelp2Dialog() - { - this.InitializeComponent(); - pictureBox1.Icon = SystemIcons.Question; - } - - #region Windows Forms Designer generated code - /// - /// This method is required for Windows Forms designer support. - /// Do not change the method contents inside the source code editor. The Forms designer might - /// not be able to load this method if it was changed manually. - /// - private void InitializeComponent() - { - this.actionLabel = new System.Windows.Forms.Label(); - this.pictureBox1 = new IconPictureBox(); - - this.SuspendLayout(); - // - // actionLabel - // - this.actionLabel.Location = new System.Drawing.Point(66, 16); - this.actionLabel.Name = "actionLabel"; - this.actionLabel.Size = new System.Drawing.Size(190, 64); - this.actionLabel.TabIndex = 1; - // - // pictureBox1 - // - this.pictureBox1.Location = new System.Drawing.Point(16, 16); - this.pictureBox1.Name = "pictureBox1"; - this.pictureBox1.Size = new System.Drawing.Size(32, 32); - this.pictureBox1.TabIndex = 0; - this.pictureBox1.TabStop = false; - // - // HtmlHelp2Dialog - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.ClientSize = new System.Drawing.Size(268, 96); - this.Controls.Add(this.actionLabel); - this.Controls.Add(this.pictureBox1); - this.Font = new System.Drawing.Font("Tahoma", 8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.ControlBox = false; - this.Name = "HtmlHelp2Dialog"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; -// this.Text = "HtmlHelp2Dialog"; - this.ResumeLayout(false); - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs deleted file mode 100644 index dc60ae5a64..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Options.cs +++ /dev/null @@ -1,98 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using ICSharpCode.SharpDevelop.Gui.OptionPanels; - using System; - using System.Windows.Forms; - using System.Xml.Serialization; - using ICSharpCode.SharpDevelop.Gui; - - public class HtmlHelp2OptionsPanel : XmlFormsOptionPanel - { - ComboBox help2Collections; - CheckBox tocPictures; - string selectedHelp2Collection = string.Empty; - - public override void LoadPanelContents() - { - SetupFromXmlStream - (this.GetType().Assembly.GetManifestResourceStream("HtmlHelp2.Resources.HtmlHelp2Options.xfrm")); - this.InitializeComponents(); - } - - public override bool StorePanelContents() - { - this.SaveHelp2Config(); - HtmlHelp2Environment.ReloadNamespace(); - return true; - } - - private void InitializeComponents() - { - selectedHelp2Collection = HtmlHelp2Environment.DefaultNamespaceName; - - help2Collections = (ComboBox)ControlDictionary["help2Collections"]; - help2Collections.SelectedIndexChanged += new EventHandler(this.NamespaceNameChanged); - - tocPictures = (CheckBox)ControlDictionary["tocPictures"]; - tocPictures.Checked = HtmlHelp2Environment.Config.TocPictures; - - if (!Help2RegistryWalker.BuildNamespacesList(help2Collections, selectedHelp2Collection)) - { - help2Collections.Enabled = false; - tocPictures.Enabled = false; - } - } - - private void NamespaceNameChanged(object sender, EventArgs e) - { - if (help2Collections.SelectedItem != null) - { - selectedHelp2Collection = - Help2RegistryWalker.GetNamespaceName(help2Collections.SelectedItem.ToString()); - } - } - - private void SaveHelp2Config() - { - HtmlHelp2Environment.Config.SelectedCollection = selectedHelp2Collection; - HtmlHelp2Environment.Config.TocPictures = tocPictures.Checked; - HtmlHelp2Environment.SaveConfiguration(); - } - } - - [XmlRoot("help2environment")] - public class HtmlHelp2Options - { - private string selectedCollection = string.Empty; - private bool tocPictures; - private bool dynamicHelpDebugInfo; - - [XmlElement("collection")] - public string SelectedCollection - { - get { return selectedCollection; } - set { selectedCollection = value; } - } - - [XmlElement("tocpictures")] - public bool TocPictures - { - get { return tocPictures; } - set { tocPictures = value; } - } - - [XmlElement("dhdebuginfos")] - public bool DynamicHelpDebugInfos - { - get { return this.dynamicHelpDebugInfo; } - set { this.dynamicHelpDebugInfo = value; } - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs deleted file mode 100644 index a95e1bc16e..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/HtmlHelp2Service.cs +++ /dev/null @@ -1,407 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using System; - using System.Globalization; - using System.IO; - using System.Windows.Forms; - using System.Xml.Serialization; - - using ICSharpCode.Core; - using MSHelpServices; - - public sealed class HtmlHelp2Environment - { - static Guid TocGuid = new Guid("314111B2-A502-11D2-BBCA-00C04F8EC294"); - static Guid IndexGuid = new Guid("314111CC-A502-11D2-BBCA-00C04F8EC294"); - static Guid QueryGuid = new Guid("31411193-A502-11D2-BBCA-00C04F8EC294"); - static HxSession session; - static IHxRegFilterList namespaceFilters; - static IHxQuery fulltextSearch; - static IHxIndex dynamicHelp; - static string defaultNamespaceName; - static string currentSelectedFilterQuery; - static string currentSelectedFilterName; - static string defaultPage = "about:blank"; - static string searchPage = "http://msdn.microsoft.com"; - static bool dynamicHelpIsBusy; - static HtmlHelp2Options config = new HtmlHelp2Options(); - - HtmlHelp2Environment() - { - } - - static HtmlHelp2Environment() - { - InitializeNamespace(); - } - - #region Properties - public static bool SessionIsInitialized - { - get { return session != null; } - } - - public static string DefaultNamespaceName - { - get { return defaultNamespaceName; } - } - - public static string CurrentFilterQuery - { - get { return currentSelectedFilterQuery; } - } - - public static string CurrentFilterName - { - get { return currentSelectedFilterName; } - } - - public static string DefaultPage - { - get { return defaultPage; } - } - - public static string SearchPage - { - get { return searchPage; } - } - - public static IHxQuery Fts - { - get { return fulltextSearch; } - } - - public static bool DynamicHelpIsBusy - { - get { return dynamicHelpIsBusy; } - } - - public static HtmlHelp2Options Config - { - get { return config; } - } - #endregion - - #region Namespace Functions - private static void LoadHelp2Config() - { - if (string.IsNullOrEmpty(defaultNamespaceName)) - { - defaultNamespaceName = - Help2RegistryWalker.GetFirstMatchingNamespaceName("MS.NETFramework.v20*"); - } - else - { - defaultNamespaceName = Help2RegistryWalker.GetFirstNamespace(defaultNamespaceName); - } - - LoadConfiguration(); - - if (!string.IsNullOrEmpty(config.SelectedCollection)) - { - defaultNamespaceName = - Help2RegistryWalker.GetFirstNamespace(config.SelectedCollection); - } - } - - public static void ReloadNamespace() - { - InitializeNamespace(); - OnNamespaceReloaded(EventArgs.Empty); - } - - private static void InitializeNamespace() - { - LoadHelp2Config(); - - if (string.IsNullOrEmpty(defaultNamespaceName)) - { - return; - } - - session = null; - - HtmlHelp2Dialog initDialog = new HtmlHelp2Dialog(); - try - { - initDialog.Text = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpUpdateCaption}"); - initDialog.ActionLabel = StringParser.Parse("${res:AddIns.HtmlHelp2.HelpUpdateInProgress}"); - initDialog.Show(); - Application.DoEvents(); - - currentSelectedFilterQuery = string.Empty; - currentSelectedFilterName = string.Empty; - - session = new HxSession(); - session.Initialize(String.Format(CultureInfo.InvariantCulture, "ms-help://{0}", defaultNamespaceName), 0); - namespaceFilters = session.GetFilterList(); - - ReloadDefaultPages(); - ReloadFTSSystem(); - ReloadDynamicHelpSystem(); - - LoggingService.Info("Help 2.0: Service sucessfully loaded"); - } - catch (System.Runtime.InteropServices.COMException cEx) - { - LoggingService.Error("Help 2.0: Cannot not initialize service; " + cEx.ToString()); - session = null; - } - finally - { - initDialog.Dispose(); - } - } - - private static void ReloadFTSSystem() - { - try - { - fulltextSearch = (IHxQuery)session.GetNavigationInterface - ("!DefaultFullTextSearch", currentSelectedFilterQuery, ref QueryGuid); - } - catch (System.Runtime.InteropServices.COMException) - { - fulltextSearch = null; - } - } - - private static void ReloadDynamicHelpSystem() - { - try - { - dynamicHelp = (IHxIndex)session.GetNavigationInterface - ("!DefaultContextWindowIndex", currentSelectedFilterQuery, ref IndexGuid); - } - catch (System.Runtime.InteropServices.COMException) - { - dynamicHelp = null; - } - } - - private static void ReloadDefaultPages() - { - defaultPage = GetDefaultPage("HomePage", "DefaultPage"); - searchPage = GetDefaultPage("SearchHelpPage", "SearchWebPage", "http://msdn.microsoft.com"); - } - - private static string GetDefaultPage(string pageName, string alternatePageName) - { - return GetDefaultPage(pageName, alternatePageName, "about:blank"); - } - - private static string GetDefaultPage(string pageName, string alternatePageName, string defaultValue) - { - if (string.IsNullOrEmpty(pageName) && string.IsNullOrEmpty(alternatePageName)) - { - throw new ArgumentNullException("pageName & alternatePageName"); - } - try - { - string result = string.Empty; - - IHxIndex namedUrlIndex = - (IHxIndex)session.GetNavigationInterface("!DefaultNamedUrlIndex", "", ref IndexGuid); - IHxTopicList topics = namedUrlIndex.GetTopicsFromString(pageName, 0); - - if (topics.Count == 0 && !string.IsNullOrEmpty(alternatePageName)) - { - topics = namedUrlIndex.GetTopicsFromString(alternatePageName, 0); - } - - if (topics.Count > 0) result = topics.ItemAt(1).URL; - if (string.IsNullOrEmpty(result)) result = defaultValue; - - return result; - } - catch (System.Runtime.InteropServices.COMException) - { - return defaultValue; - } - } - - public static IHxHierarchy GetTocHierarchy(string filterQuery) - { - IHxHierarchy defaultToc = - (IHxHierarchy)session.GetNavigationInterface("!DefaultTOC", filterQuery, ref TocGuid); - return defaultToc; - } - - public static IHxIndex GetIndex(string filterQuery) - { - IHxIndex defaultIndex = - (IHxIndex)session.GetNavigationInterface("!DefaultKeywordIndex", filterQuery, ref IndexGuid); - return defaultIndex; - } - - public static void BuildFilterList(ComboBox filterCombobox) - { - if (filterCombobox == null) - { - throw new ArgumentNullException("filterCombobox"); - } - - filterCombobox.Items.Clear(); - filterCombobox.BeginUpdate(); - - if (namespaceFilters == null || namespaceFilters.Count == 0) - { - filterCombobox.Items.Add - (StringParser.Parse("${res:AddIns.HtmlHelp2.DefaultEmptyFilter}")); - filterCombobox.SelectedIndex = 0; - } - else - { - foreach (IHxRegFilter filter in namespaceFilters) - { - string filterName = - (string)filter.GetProperty(HxRegFilterPropId.HxRegFilterName); - filterCombobox.Items.Add(filterName); - - if (string.IsNullOrEmpty(currentSelectedFilterName)) - { - currentSelectedFilterName = filterName; - } - } - - if (string.IsNullOrEmpty(currentSelectedFilterName)) - filterCombobox.SelectedIndex = 0; - else - filterCombobox.SelectedIndex = filterCombobox.Items.IndexOf(currentSelectedFilterName); - } - filterCombobox.EndUpdate(); - } - - public static string FindFilterQuery(string filterName) - { - if (string.Compare(filterName, currentSelectedFilterName) == 0) - { - return currentSelectedFilterQuery; - } - if (namespaceFilters == null || namespaceFilters.Count == 0) - { - return string.Empty; - } - - IHxRegFilter filter = namespaceFilters.FindFilter(filterName); - if (filter == null) - { - return string.Empty; - } - - currentSelectedFilterName = filterName; - currentSelectedFilterQuery = - (string)filter.GetProperty(HxRegFilterPropId.HxRegFilterQuery); - - OnFilterQueryChanged(EventArgs.Empty); - - try - { - ReloadFTSSystem(); - ReloadDynamicHelpSystem(); - ReloadDefaultPages(); - } - catch (System.Runtime.InteropServices.COMException cEx) - { - LoggingService.Error("Help 2.0: Cannot not initialize service; " + cEx.ToString()); - } - return currentSelectedFilterQuery; - } - - public static IHxTopicList GetMatchingTopicsForDynamicHelp(string searchTerm) - { - if (dynamicHelpIsBusy || dynamicHelp == null || string.IsNullOrEmpty(searchTerm)) - { - return null; - } - IHxTopicList topics; - try - { - dynamicHelpIsBusy = true; - topics = dynamicHelp.GetTopicsFromString(searchTerm, 0); - LoggingService.Info("Help 2.0: Dynamic Help called"); - } - catch (System.Runtime.InteropServices.COMException) - { - LoggingService.Error("Help 2.0: Dynamic Help search failed"); - topics = null; - } - finally - { - dynamicHelpIsBusy = false; - } - return topics; - } - #endregion - - #region Event Handling - public static event EventHandler FilterQueryChanged; - public static event EventHandler NamespaceReloaded; - - private static void OnFilterQueryChanged(EventArgs e) - { - if(FilterQueryChanged != null) - { - FilterQueryChanged(null, e); - } - } - - private static void OnNamespaceReloaded(EventArgs e) - { - if(NamespaceReloaded != null) - { - NamespaceReloaded(null, e); - } - } - #endregion - - #region Configuration - public static void LoadConfiguration() - { - string configFile = Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml"); - if (!File.Exists(configFile)) - { - return; - } - try - { - XmlSerializer serialize = new XmlSerializer(typeof(HtmlHelp2Options)); - TextReader file = new StreamReader(configFile); - config = (HtmlHelp2Options)serialize.Deserialize(file); - file.Close(); - - LoggingService.Info("Help 2.0: Configuration successfully loaded"); - } - catch (InvalidOperationException) - { - LoggingService.Error("Help 2.0: Error while trying to load configuration"); - } - } - - public static void SaveConfiguration() - { - string configFile = Path.Combine(PropertyService.ConfigDirectory, "help2environment.xml"); - try - { - XmlSerializer serialize = new XmlSerializer(typeof(HtmlHelp2Options)); - TextWriter file = new StreamWriter(configFile); - serialize.Serialize(file, config); - file.Close(); - - LoggingService.Info("Help 2.0: Configuration successfully saved"); - } - catch (InvalidOperationException) - { - LoggingService.Error("Help 2.0: Error while trying to save configuration"); - } - } - #endregion - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/ResourcesHelper.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/ResourcesHelper.cs deleted file mode 100644 index 189e3a904e..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/ResourcesHelper.cs +++ /dev/null @@ -1,38 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using System; - using System.Drawing; - using System.Reflection; - using System.Resources; - - public sealed class ResourcesHelper - { - static ResourcesHelper instance = new ResourcesHelper(); - - public static Bitmap GetBitmap(string resourceName) - { - Assembly assembly = typeof(ResourcesHelper).Assembly; - string fullName = string.Format(null, "HtmlHelp2.Resources.{0}", resourceName); - return new Bitmap(assembly.GetManifestResourceStream(fullName)); - } - - public static Image GetImage(string imageName) - { - return instance.ImageResourceHelper.GetObject(imageName) as Image; - } - - ResourceManager ImageResourceHelper; - - ResourcesHelper() - { - ImageResourceHelper = new ResourceManager("HtmlHelp2.Resources", GetType().Assembly); - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/SharpDevLanguageClass.cs b/src/AddIns/Misc/HtmlHelp2/Project/src/Service/SharpDevLanguageClass.cs deleted file mode 100644 index 59750cf2df..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/Project/src/Service/SharpDevLanguageClass.cs +++ /dev/null @@ -1,131 +0,0 @@ -// -// -// -// -// $Revision$ -// - -namespace HtmlHelp2.Environment -{ - using System; - using System.Collections.Generic; - using ICSharpCode.SharpDevelop; - using ICSharpCode.SharpDevelop.Project; - using MSHelpServices; - - public sealed class SharpDevLanguage - { - static Dictionary languages = InitializeLanguages(); - - static Dictionary InitializeLanguages() - { - Dictionary result = new Dictionary(); - result.Add("C#", "CSharp"); - result.Add("VBNet", "VB"); - - return result; - } - - SharpDevLanguage() - { - } - - private static int DevLangCounter(IHxTopic topic) - { - if (topic == null) - { - return 0; - } - - int counter = 0; - IHxAttributeList topicAttributes = topic.Attributes; - if (topicAttributes == null || topicAttributes.Count == 0) - { - return 0; - } - - foreach (IHxAttribute attr in topicAttributes) - { - if (String.Compare(attr.DisplayName, "DevLang") == 0) - { - counter++; - } - } - return counter; - } - - public static bool CheckTopicLanguage(IHxTopic topic) - { - if (ProjectService.CurrentProject != null) - { - return CheckTopicLanguage(topic, ProjectService.CurrentProject.Language); - } - else - { - return true; - } - } - - public static bool CheckTopicLanguage(IHxTopic topic, string expectedLanguage) - { - if (string.IsNullOrEmpty(expectedLanguage)) - { - return true; - } - if (topic == null) - { - return false; - } - - string tempLanguage = String.Empty; - if (!languages.ContainsKey(expectedLanguage) || - !languages.TryGetValue(expectedLanguage, out tempLanguage)) - { - tempLanguage = expectedLanguage; - } - - return (string.IsNullOrEmpty(tempLanguage) || topic.HasAttribute("DevLang", tempLanguage)); - } - - public static bool CheckUniqueTopicLanguage(IHxTopic topic) - { - if (ProjectService.CurrentProject != null) - { - return CheckUniqueTopicLanguage(topic, ProjectService.CurrentProject.Language); - } - else - { - return CheckUniqueTopicLanguage(topic, string.Empty); - } - } - - public static bool CheckUniqueTopicLanguage(IHxTopic topic, string expectedLanguage) - { - return (CheckTopicLanguage(topic, expectedLanguage) && DevLangCounter(topic) == 1); - } - - public static string GetPatchedLanguage() - { - if (ProjectService.CurrentProject == null) - return GetPatchedLanguage(AmbienceService.DefaultAmbienceName); - else - return GetPatchedLanguage(ProjectService.CurrentProject.Language); - } - - public static string GetPatchedLanguage(string expectedLanguage) - { - string tempLanguage = expectedLanguage; - - if (!string.IsNullOrEmpty(tempLanguage)) - { - if (!languages.ContainsKey(expectedLanguage) || - !languages.TryGetValue(expectedLanguage, out tempLanguage)) - { - tempLanguage = expectedLanguage; - } - } - - return tempLanguage; - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/AxMSHelpControls.cs b/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/AxMSHelpControls.cs deleted file mode 100644 index 4dd8f3ff61..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/AxMSHelpControls.cs +++ /dev/null @@ -1,769 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50215.44 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -[assembly: System.Reflection.AssemblyVersion("1.0.0.0")] -[assembly: System.Windows.Forms.AxHost.TypeLibraryTimeStamp("09.04.2005 00:38:34")] - -namespace AxMSHelpControls { - - - [System.Windows.Forms.AxHost.ClsidAttribute("{314111b8-a502-11d2-bbca-00c04f8ec294}")] - [System.ComponentModel.DesignTimeVisibleAttribute(true)] - public class AxHxTocCtrl : System.Windows.Forms.AxHost { - - private MSHelpControls.IHxTreeView ocx; - - private AxHxTocCtrlEventMulticaster eventMulticaster; - - private System.Windows.Forms.AxHost.ConnectionPointCookie cookie; - - public AxHxTocCtrl() : - base("314111b8-a502-11d2-bbca-00c04f8ec294") { - } - - [System.ComponentModel.Browsable(false)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4096)] - public virtual MSHelpServices.IHxHierarchy Hierarchy { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Hierarchy", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Hierarchy; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Hierarchy", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Hierarchy = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4100)] - public virtual int ImageList { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("ImageList", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.ImageList; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("ImageList", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.ImageList = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4097)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual bool HideSelection { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HideSelection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.HideSelection; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HideSelection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.HideSelection = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4098)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxTreeLineStyleConstant LineStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LineStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.LineStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LineStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.LineStyle = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4099)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxTreeStyleConstant TreeStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("TreeStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.TreeStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("TreeStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.TreeStyle = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-501)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Color BackColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.BackColor))); - } - else { - return base.BackColor; - } - } - set { - base.BackColor = value; - if ((this.ocx != null)) { - this.ocx.BackColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-513)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Color ForeColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.ForeColor))); - } - else { - return base.ForeColor; - } - } - set { - base.ForeColor = value; - if ((this.ocx != null)) { - this.ocx.ForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-504)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxBorderStyle BorderStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.BorderStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.BorderStyle = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-520)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxAppearanceConstant Appearance { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Appearance; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Appearance = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-521)] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public virtual MSHelpControls.HxMousePointerConstant MousePointer { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.MousePointer; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.MousePointer = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-512)] - [System.Runtime.InteropServices.ComAliasNameAttribute("stdole.StdFont")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Font Font { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetFontFromIFont(this.ocx.Font); - } - else { - return base.Font; - } - } - set { - base.Font = value; - if ((this.ocx != null)) { - this.ocx.Font = ((stdole.StdFont)(GetIFontFromFont(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4102)] - public virtual int Selection { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Selection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Selection; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4103)] - public virtual short LangId { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.LangId; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.LangId = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(4104)] - public virtual MSHelpControls.HxFontSourceConstant FontSource { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.FontSource; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FontSource = value; - } - } - - public event IHxTreeViewEvents_NodeClickEventHandler NodeClick; - - public event IHxTreeViewEvents_NodeRightClickEventHandler NodeRightClick; - - public virtual void Refresh() { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Refresh", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.Refresh(); - } - - public virtual void Synchronize(string bstrURL) { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Synchronize", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.Synchronize(bstrURL); - } - - protected override void CreateSink() { - try { - this.eventMulticaster = new AxHxTocCtrlEventMulticaster(this); - this.cookie = new System.Windows.Forms.AxHost.ConnectionPointCookie(this.ocx, this.eventMulticaster, typeof(MSHelpControls.IHxTreeViewEvents)); - } - catch (System.Exception ) { - } - } - - protected override void DetachSink() { - try { - this.cookie.Disconnect(); - } - catch (System.Exception ) { - } - } - - protected override void AttachInterfaces() { - try { - this.ocx = ((MSHelpControls.IHxTreeView)(this.GetOcx())); - } - catch (System.Exception ) { - } - } - - internal void RaiseOnNodeClick(object sender, IHxTreeViewEvents_NodeClickEvent e) { - if ((this.NodeClick != null)) { - this.NodeClick(sender, e); - } - } - - internal void RaiseOnNodeRightClick(object sender, IHxTreeViewEvents_NodeRightClickEvent e) { - if ((this.NodeRightClick != null)) { - this.NodeRightClick(sender, e); - } - } - } - - public delegate void IHxTreeViewEvents_NodeClickEventHandler(object sender, IHxTreeViewEvents_NodeClickEvent e); - - public class IHxTreeViewEvents_NodeClickEvent { - - public int hNode; - - public IHxTreeViewEvents_NodeClickEvent(int hNode) { - this.hNode = hNode; - } - } - - public delegate void IHxTreeViewEvents_NodeRightClickEventHandler(object sender, IHxTreeViewEvents_NodeRightClickEvent e); - - public class IHxTreeViewEvents_NodeRightClickEvent { - - public int hNode; - - public int x; - - public int y; - - public IHxTreeViewEvents_NodeRightClickEvent(int hNode, int x, int y) { - this.hNode = hNode; - this.x = x; - this.y = y; - } - } - - [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)] - public class AxHxTocCtrlEventMulticaster : MSHelpControls.IHxTreeViewEvents { - - private AxHxTocCtrl parent; - - public AxHxTocCtrlEventMulticaster(AxHxTocCtrl parent) { - this.parent = parent; - } - - public virtual void NodeClick(int hNode) { - IHxTreeViewEvents_NodeClickEvent nodeclickEvent = new IHxTreeViewEvents_NodeClickEvent(hNode); - this.parent.RaiseOnNodeClick(this.parent, nodeclickEvent); - } - - public virtual void NodeRightClick(int hNode, int x, int y) { - IHxTreeViewEvents_NodeRightClickEvent noderightclickEvent = new IHxTreeViewEvents_NodeRightClickEvent(hNode, x, y); - this.parent.RaiseOnNodeRightClick(this.parent, noderightclickEvent); - } - } - - [System.Windows.Forms.AxHost.ClsidAttribute("{314111c6-a502-11d2-bbca-00c04f8ec294}")] - [System.ComponentModel.DesignTimeVisibleAttribute(true)] - public class AxHxIndexCtrl : System.Windows.Forms.AxHost { - - private MSHelpControls.IHxIndexView ocx; - - private AxHxIndexCtrlEventMulticaster eventMulticaster; - - private System.Windows.Forms.AxHost.ConnectionPointCookie cookie; - - public AxHxIndexCtrl() : - base("314111c6-a502-11d2-bbca-00c04f8ec294") { - } - - [System.ComponentModel.Browsable(false)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16384)] - public virtual MSHelpServices.IHxIndex IndexData { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("IndexData", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.IndexData; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("IndexData", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.IndexData = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16385)] - public virtual int Selection { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Selection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Selection; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Selection", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Selection = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-501)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public override System.Drawing.Color BackColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.BackColor))); - } - else { - return base.BackColor; - } - } - set { - base.BackColor = value; - if ((this.ocx != null)) { - this.ocx.BackColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-513)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public override System.Drawing.Color ForeColor { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetColorFromOleColor(((uint)(this.ocx.ForeColor))); - } - else { - return base.ForeColor; - } - } - set { - base.ForeColor = value; - if ((this.ocx != null)) { - this.ocx.ForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-504)] - public virtual MSHelpControls.HxBorderStyle BorderStyle { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.BorderStyle; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("BorderStyle", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.BorderStyle = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-520)] - public virtual MSHelpControls.HxAppearanceConstant Appearance { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.Appearance; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Appearance", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.Appearance = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-521)] - public virtual MSHelpControls.HxMousePointerConstant MousePointer { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.MousePointer; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("MousePointer", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.MousePointer = value; - } - } - - [System.ComponentModel.Browsable(true)] - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(-512)] - [System.Runtime.InteropServices.ComAliasNameAttribute("stdole.StdFont")] - [System.ComponentModel.Bindable(System.ComponentModel.BindableSupport.Yes)] - public override System.Drawing.Font Font { - get { - if (((this.ocx != null) - && (this.PropsValid() == true))) { - return GetFontFromIFont(this.ocx.Font); - } - else { - return base.Font; - } - } - set { - base.Font = value; - if ((this.ocx != null)) { - this.ocx.Font = ((stdole.StdFont)(GetIFontFromFont(value))); - } - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16388)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color HighlightForeColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.HighlightForeColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.HighlightForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16389)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color HighlightBackColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.HighlightBackColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("HighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.HighlightBackColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16390)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color FocusHighlightForeColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.FocusHighlightForeColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightForeColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FocusHighlightForeColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16391)] - [System.Runtime.InteropServices.ComAliasNameAttribute("System.UInt32")] - public virtual System.Drawing.Color FocusHighlightBackColor { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return GetColorFromOleColor(((uint)(this.ocx.FocusHighlightBackColor))); - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FocusHighlightBackColor", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FocusHighlightBackColor = ((uint)(GetOleColorFromColor(value))); - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16392)] - public virtual short LangId { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.LangId; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("LangId", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.LangId = value; - } - } - - [System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)] - [System.Runtime.InteropServices.DispIdAttribute(16393)] - public virtual MSHelpControls.HxFontSourceConstant FontSource { - get { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertyGet); - } - return this.ocx.FontSource; - } - set { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("FontSource", System.Windows.Forms.AxHost.ActiveXInvokeKind.PropertySet); - } - this.ocx.FontSource = value; - } - } - - public event IHxIndexViewEvents_ItemClickEventHandler ItemClick; - - public event IHxIndexViewEvents_ItemSelectEventHandler ItemSelect; - - public virtual void SelectItem(int iItem) { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("SelectItem", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.SelectItem(iItem); - } - - public virtual void ClickItem(int iItem) { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("ClickItem", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.ClickItem(iItem); - } - - public virtual void Refresh() { - if ((this.ocx == null)) { - throw new System.Windows.Forms.AxHost.InvalidActiveXStateException("Refresh", System.Windows.Forms.AxHost.ActiveXInvokeKind.MethodInvoke); - } - this.ocx.Refresh(); - } - - protected override void CreateSink() { - try { - this.eventMulticaster = new AxHxIndexCtrlEventMulticaster(this); - this.cookie = new System.Windows.Forms.AxHost.ConnectionPointCookie(this.ocx, this.eventMulticaster, typeof(MSHelpControls.IHxIndexViewEvents)); - } - catch (System.Exception ) { - } - } - - protected override void DetachSink() { - try { - this.cookie.Disconnect(); - } - catch (System.Exception ) { - } - } - - protected override void AttachInterfaces() { - try { - this.ocx = ((MSHelpControls.IHxIndexView)(this.GetOcx())); - } - catch (System.Exception ) { - } - } - - internal void RaiseOnItemClick(object sender, IHxIndexViewEvents_ItemClickEvent e) { - if ((this.ItemClick != null)) { - this.ItemClick(sender, e); - } - } - - internal void RaiseOnItemSelect(object sender, IHxIndexViewEvents_ItemSelectEvent e) { - if ((this.ItemSelect != null)) { - this.ItemSelect(sender, e); - } - } - } - - public delegate void IHxIndexViewEvents_ItemClickEventHandler(object sender, IHxIndexViewEvents_ItemClickEvent e); - - public class IHxIndexViewEvents_ItemClickEvent { - - public int iItem; - - public IHxIndexViewEvents_ItemClickEvent(int iItem) { - this.iItem = iItem; - } - } - - public delegate void IHxIndexViewEvents_ItemSelectEventHandler(object sender, IHxIndexViewEvents_ItemSelectEvent e); - - public class IHxIndexViewEvents_ItemSelectEvent { - - public int iItem; - - public IHxIndexViewEvents_ItemSelectEvent(int iItem) { - this.iItem = iItem; - } - } - - [System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)] - public class AxHxIndexCtrlEventMulticaster : MSHelpControls.IHxIndexViewEvents { - - private AxHxIndexCtrl parent; - - public AxHxIndexCtrlEventMulticaster(AxHxIndexCtrl parent) { - this.parent = parent; - } - - public virtual void ItemClick(int iItem) { - IHxIndexViewEvents_ItemClickEvent itemclickEvent = new IHxIndexViewEvents_ItemClickEvent(iItem); - this.parent.RaiseOnItemClick(this.parent, itemclickEvent); - } - - public virtual void ItemSelect(int iItem) { - IHxIndexViewEvents_ItemSelectEvent itemselectEvent = new IHxIndexViewEvents_ItemSelectEvent(iItem); - this.parent.RaiseOnItemSelect(this.parent, itemselectEvent); - } - } -} diff --git a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/MSHelpControls.dll b/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/MSHelpControls.dll deleted file mode 100755 index a39e0c4526..0000000000 Binary files a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/MSHelpControls.dll and /dev/null differ diff --git a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/MSHelpServices.dll b/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/MSHelpServices.dll deleted file mode 100755 index 6c5a7b75b8..0000000000 Binary files a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/MSHelpServices.dll and /dev/null differ diff --git a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/import.bat b/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/import.bat deleted file mode 100755 index a0b5adaab9..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/import.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off - -del *.dll -del *.cs - - -setlocal -set AxImp="C:\Programme\Microsoft Visual Studio 8\SDK\v2.0\Bin\AxImp.exe" -%AxImp% -source "%CommonProgramFiles%\Microsoft Shared\help\hxvz.dll" -set AxImp= - -del *.pdb -del Ax*.dll - -pause \ No newline at end of file diff --git a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/import.txt b/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/import.txt deleted file mode 100644 index 30fc20ef9a..0000000000 --- a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/import.txt +++ /dev/null @@ -1,16 +0,0 @@ -The "MSHelpControls.dll", "MSHelpServices.dll" and the "stdole.dll" are generated .NET wrappers. There is a fourth file, you can find in the "source\HtmlHelp2\Help2Service" folder, called "AxMSHelpControls.cs". - -If you want to re-generate the wrapper files, just call the "import.bat" file. But first make sure that all paths are valid. These are the two important lines - - set AxImp="K:\Programme\Microsoft.NET\SDK\v2.0\Bin\AxImp.exe" - %AxImp% -source "%CommonProgramFiles%\Microsoft Shared\help\hxvz.dll" - - -The AxImp tool will create an "AxMSHelpControls.cs" file and an "AxMSHelpControls.dll" file. My addin was build with the CSharp source file. Please copy the re-created version into the "source\HtmlHelp2\Help2Service" folder, overwriting the existing file. - - -NOTE: It's not necessary to rename the wrapper libraries with some kind of an "Interop." prefix or something like that. There are no native Windows libraries with the same names. - - -Mathias Simmack -(2005-06-24) \ No newline at end of file diff --git a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/stdole.dll b/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/stdole.dll deleted file mode 100755 index 3aa2849449..0000000000 Binary files a/src/AddIns/Misc/HtmlHelp2/RequiredLibraries/stdole.dll and /dev/null differ diff --git a/src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj b/src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj index 1f03aec459..10cdb66070 100644 --- a/src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj +++ b/src/AddIns/Misc/ReflectorAddIn/ReflectorAddIn/Project/ReflectorAddIn.csproj @@ -1,4 +1,5 @@ - + + {8AA421C8-D7AF-4957-9F43-5135328ACB24} Debug @@ -66,11 +67,6 @@ - - {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} - ICSharpCode.TextEditor - False - {2748AD25-9C63-4E12-877B-4DCE96FBED54} ICSharpCode.SharpDevelop diff --git a/src/AddIns/Misc/SharpRefactoring/Test/SharpRefactoring.Tests.csproj b/src/AddIns/Misc/SharpRefactoring/Test/SharpRefactoring.Tests.csproj index ca375c0694..2b09917433 100644 --- a/src/AddIns/Misc/SharpRefactoring/Test/SharpRefactoring.Tests.csproj +++ b/src/AddIns/Misc/SharpRefactoring/Test/SharpRefactoring.Tests.csproj @@ -13,6 +13,7 @@ False 4 false + ..\..\..\..\..\bin\UnitTests\ x86 @@ -22,7 +23,6 @@ 4096 - ..\..\..\..\..\bin\UnitTests\ true Full False @@ -30,7 +30,6 @@ DEBUG;TRACE - bin\Release\ False None True diff --git a/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs b/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs index 935a00ba6e..877064944a 100644 --- a/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs +++ b/src/AddIns/Misc/StartPage/Project/Src/RecentProjectsControl.xaml.cs @@ -56,6 +56,7 @@ namespace ICSharpCode.StartPage { List items = new List(); foreach (string path in (string[])state) { + Core.LoggingService.Debug("RecentProjectsControl: Looking up path '" + path + "'"); FileInfo file = new FileInfo(path); if (file.Exists) { items.Add( diff --git a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs index 0ca1b57178..91f0daed28 100644 --- a/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs +++ b/src/AddIns/Misc/SubversionAddIn/Project/Src/SvnClientWrapper.cs @@ -180,7 +180,13 @@ namespace ICSharpCode.Svn throw new ObjectDisposedException("SvnClientWrapper"); } - void BeforeOperation(string operationName) + void BeforeWriteOperation(string operationName) + { + BeforeReadOperation(operationName); + ClearStatusCache(); + } + + void BeforeReadOperation(string operationName) { // before any subversion operation, ensure the object is not disposed // and register authorization if necessary @@ -198,42 +204,51 @@ namespace ICSharpCode.Svn OperationFinished(this, EventArgs.Empty); } + // We cache SingleStatus results because WPF asks our Condition several times + // per menu entry; and it would be extremely slow to hit the hard disk every time (SD2-1672) + Dictionary statusCache = new Dictionary(StringComparer.OrdinalIgnoreCase); + public void ClearStatusCache() { CheckNotDisposed(); + statusCache.Clear(); } public Status SingleStatus(string filename) { + filename = FileUtility.NormalizePath(filename); + Status result = null; + if (statusCache.TryGetValue(filename, out result)) { + Debug("SVN: SingleStatus(" + filename + ") = cached " + result.TextStatus); + return result; + } Debug("SVN: SingleStatus(" + filename + ")"); - BeforeOperation("stat"); + BeforeReadOperation("stat"); try { - filename = FileUtility.NormalizePath(filename); SvnStatusArgs args = new SvnStatusArgs { Revision = SvnRevision.Working, RetrieveAllEntries = true, RetrieveIgnoredEntries = true, Depth = SvnDepth.Empty }; - Status result = null; client.Status( filename, args, delegate (object sender, SvnStatusEventArgs e) { Debug("SVN: SingleStatus.callback(" + e.FullPath + "," + e.LocalContentStatus + ")"); - System.Diagnostics.Debug.Assert(filename.Equals(e.FullPath, StringComparison.OrdinalIgnoreCase)); + System.Diagnostics.Debug.Assert(filename.ToString().Equals(e.FullPath, StringComparison.OrdinalIgnoreCase)); result = new Status { Copied = e.LocalCopied, TextStatus = ToStatusKind(e.LocalContentStatus) }; } ); - if (result != null) { - return result; - } else { - return new Status { + if (result == null) { + result = new Status { TextStatus = StatusKind.None }; } + statusCache.Add(filename, result); + return result; } catch (SvnException ex) { throw new SvnClientException(ex); } finally { @@ -252,7 +267,7 @@ namespace ICSharpCode.Svn public void Add(string filename, Recurse recurse) { Debug("SVN: Add(" + filename + ", " + recurse + ")"); - BeforeOperation("add"); + BeforeWriteOperation("add"); try { client.Add(filename, ConvertDepth(recurse)); } catch (SvnException ex) { @@ -265,7 +280,7 @@ namespace ICSharpCode.Svn public string GetPropertyValue(string fileName, string propertyName) { Debug("SVN: GetPropertyValue(" + fileName + ", " + propertyName + ")"); - BeforeOperation("propget"); + BeforeReadOperation("propget"); try { string propertyValue; if (client.GetProperty(fileName, propertyName, out propertyValue)) @@ -282,7 +297,7 @@ namespace ICSharpCode.Svn public void SetPropertyValue(string fileName, string propertyName, string newPropertyValue) { Debug("SVN: SetPropertyValue(" + fileName + ", " + propertyName + ", " + newPropertyValue + ")"); - BeforeOperation("propset"); + BeforeWriteOperation("propset"); try { if (newPropertyValue != null) client.SetProperty(fileName, propertyName, newPropertyValue); @@ -298,7 +313,7 @@ namespace ICSharpCode.Svn public void Delete(string[] files, bool force) { Debug("SVN: Delete(" + string.Join(",", files) + ", " + force + ")"); - BeforeOperation("delete"); + BeforeWriteOperation("delete"); try { client.Delete( files, @@ -315,7 +330,7 @@ namespace ICSharpCode.Svn public void Revert(string[] files, Recurse recurse) { Debug("SVN: Revert(" + string.Join(",", files) + ", " + recurse + ")"); - BeforeOperation("revert"); + BeforeWriteOperation("revert"); try { client.Revert( files, @@ -332,7 +347,7 @@ namespace ICSharpCode.Svn public void Move(string from, string to, bool force) { Debug("SVN: Move(" + from + ", " + to + ", " + force + ")"); - BeforeOperation("move"); + BeforeWriteOperation("move"); try { client.Move( from, to, @@ -349,7 +364,7 @@ namespace ICSharpCode.Svn public void Copy(string from, string to) { Debug("SVN: Copy(" + from + ", " + to); - BeforeOperation("copy"); + BeforeWriteOperation("copy"); try { client.Copy(from, to); } catch (SvnException ex) { @@ -385,7 +400,7 @@ namespace ICSharpCode.Svn { Debug("SVN: Log({" + string.Join(",", paths) + "}, " + start + ", " + end + ", " + limit + ", " + discoverChangePaths + ", " + strictNodeHistory + ")"); - BeforeOperation("log"); + BeforeReadOperation("log"); try { client.Log( paths, diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs index 629fcac2a3..0b59d89644 100644 --- a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector.AddIn/AnalyticsMonitor.cs @@ -25,6 +25,7 @@ namespace ICSharpCode.UsageDataCollector public sealed class AnalyticsMonitor : IAnalyticsMonitor { const string UploadUrl = "http://usagedatacollector.sharpdevelop.net/upload/UploadUsageData.svc"; + const string ProductName = "sharpdevelop"; public static readonly Uri PrivacyStatementUrl = new Uri("http://www.icsharpcode.net/OpenSource/SD/UsageDataCollector/"); public static readonly AnalyticsMonitor Instance = new AnalyticsMonitor(); @@ -110,7 +111,7 @@ namespace ICSharpCode.UsageDataCollector } } if (sessionOpened) { - UsageDataUploader uploader = new UsageDataUploader(dbFileName); + UsageDataUploader uploader = new UsageDataUploader(dbFileName, ProductName); uploader.EnvironmentDataForDummySession = appEnvironmentProperties; ThreadPool.QueueUserWorkItem(delegate { uploader.StartUpload(UploadUrl); }); } @@ -131,6 +132,11 @@ namespace ICSharpCode.UsageDataCollector if (!string.IsNullOrEmpty(PROCESSOR_ARCHITECTURE)) { properties.Add(new UsageDataEnvironmentProperty { Name = "architecture", Value = PROCESSOR_ARCHITECTURE }); } + #pragma warning disable 0162 + if (RevisionClass.BranchName != null) { + properties.Add(new UsageDataEnvironmentProperty { Name = "branch", Value = RevisionClass.BranchName }); + } + #pragma warning restore 0162 #if DEBUG properties.Add(new UsageDataEnvironmentProperty { Name = "debug", Value = "true" }); #endif @@ -148,7 +154,7 @@ namespace ICSharpCode.UsageDataCollector if (session != null) session.Flush(); } - UsageDataUploader uploader = new UsageDataUploader(dbFileName); + UsageDataUploader uploader = new UsageDataUploader(dbFileName, ProductName); return uploader.GetTextForStoredData(); } diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataSessionWriter.cs b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataSessionWriter.cs index 222c839965..52beefe793 100644 --- a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataSessionWriter.cs +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataSessionWriter.cs @@ -35,6 +35,8 @@ namespace ICSharpCode.UsageDataCollector SQLiteConnection connection; long sessionID; Timer timer; + DateTime startTime; + Stopwatch stopwatch; /// /// Opens/Creates the database and starts writing a new session to it. @@ -172,10 +174,13 @@ namespace ICSharpCode.UsageDataCollector void StartSession() { + startTime = DateTime.UtcNow; + stopwatch = Stopwatch.StartNew(); using (SQLiteTransaction transaction = this.connection.BeginTransaction()) { using (SQLiteCommand cmd = this.connection.CreateCommand()) { - cmd.CommandText = "INSERT INTO Sessions (startTime) VALUES (datetime('now'));" + + cmd.CommandText = "INSERT INTO Sessions (startTime) VALUES (?);" + "SELECT last_insert_rowid();"; + cmd.Parameters.Add(new SQLiteParameter { Value = TimeToString(startTime) }); sessionID = (long)cmd.ExecuteScalar(); } AddEnvironmentData(GetDefaultEnvironmentData()); @@ -183,12 +188,18 @@ namespace ICSharpCode.UsageDataCollector } } + DateTime GetNow() + { + return startTime + stopwatch.Elapsed; + } + void EndSession() { using (SQLiteTransaction transaction = this.connection.BeginTransaction()) { FlushOutstandingChanges(); using (SQLiteCommand cmd = this.connection.CreateCommand()) { - cmd.CommandText = "UPDATE Sessions SET endTime = datetime('now') WHERE id = ?;"; + cmd.CommandText = "UPDATE Sessions SET endTime = ? WHERE id = ?;"; + cmd.Parameters.Add(new SQLiteParameter { Value = TimeToString(GetNow()) }); cmd.Parameters.Add(new SQLiteParameter { Value = sessionID }); cmd.ExecuteNonQuery(); } @@ -239,7 +250,7 @@ namespace ICSharpCode.UsageDataCollector lock (lockObj) { if (isDisposed) throw new ObjectDisposedException(GetType().Name); - FeatureUse featureUse = new FeatureUse(this); + FeatureUse featureUse = new FeatureUse(this, GetNow()); featureUse.name = featureName; featureUse.activation = activationMethod; delayedStart.Enqueue(featureUse); @@ -252,11 +263,16 @@ namespace ICSharpCode.UsageDataCollector lock (lockObj) { if (isDisposed) return; - featureUse.endTime = DateTime.UtcNow; + featureUse.endTime = GetNow(); delayedEnd.Enqueue(featureUse); } } + static string TimeToString(DateTime time) + { + return time.ToString("yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture); + } + void FlushOutstandingChanges() { //Console.WriteLine("Flushing {0} starts and {1} ends", delayedStart.Count, delayedEnd.Count); @@ -275,7 +291,7 @@ namespace ICSharpCode.UsageDataCollector cmd.Parameters.Add(activationMethod = new SQLiteParameter()); while (delayedStart.Count > 0) { FeatureUse use = delayedStart.Dequeue(); - time.Value = use.startTime.ToString("yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture); + time.Value = TimeToString(use.startTime); feature.Value = use.name; activationMethod.Value = use.activation; @@ -291,7 +307,7 @@ namespace ICSharpCode.UsageDataCollector cmd.Parameters.Add(id = new SQLiteParameter()); while (delayedEnd.Count > 0) { FeatureUse use = delayedEnd.Dequeue(); - endTime.Value = use.endTime.ToString("yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture); + endTime.Value = TimeToString(use.endTime); id.Value = use.rowId; cmd.ExecuteNonQuery(); } @@ -424,8 +440,9 @@ namespace ICSharpCode.UsageDataCollector // first, insert the exception (it's most important to have) using (SQLiteCommand cmd = this.connection.CreateCommand()) { cmd.CommandText = "INSERT INTO Exceptions (session, time, type, stackTrace)" + - " VALUES (?, datetime('now'), ?, ?);"; + " VALUES (?, ?, ?, ?);"; cmd.Parameters.Add(new SQLiteParameter { Value = sessionID }); + cmd.Parameters.Add(new SQLiteParameter { Value = TimeToString(GetNow()) }); cmd.Parameters.Add(new SQLiteParameter { Value = exceptionType }); cmd.Parameters.Add(new SQLiteParameter { Value = stacktrace }); cmd.ExecuteNonQuery(); @@ -458,14 +475,15 @@ namespace ICSharpCode.UsageDataCollector /// public sealed class FeatureUse { - internal readonly DateTime startTime = DateTime.UtcNow; + internal readonly DateTime startTime; internal DateTime endTime; internal string name, activation; internal long rowId; - UsageDataSessionWriter writer; + readonly UsageDataSessionWriter writer; - internal FeatureUse(UsageDataSessionWriter writer) + internal FeatureUse(UsageDataSessionWriter writer, DateTime startTime) { + this.startTime = startTime; this.writer = writer; } diff --git a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataUploader.cs b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataUploader.cs index d907a174c4..42f1d3613a 100644 --- a/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataUploader.cs +++ b/src/AddIns/Misc/UsageDataCollector/UsageDataCollector/UsageDataUploader.cs @@ -28,13 +28,19 @@ namespace ICSharpCode.UsageDataCollector public class UsageDataUploader { string databaseFileName; + string productName; /// /// Creates a new UsageDataUploader. /// - public UsageDataUploader(string databaseFileName) + public UsageDataUploader(string databaseFileName, string productName) { + if (databaseFileName == null) + throw new ArgumentNullException("databaseFileName"); + if (productName == null) + throw new ArgumentNullException("productName"); this.databaseFileName = databaseFileName; + this.productName = productName; } /// @@ -140,7 +146,7 @@ namespace ICSharpCode.UsageDataCollector UdcProxy.UDCUploadServiceClient client = new UdcProxy.UDCUploadServiceClient(binding, endpoint); try { - client.BeginUploadUsageData("sharpdevelop", new MemoryStream(data), + client.BeginUploadUsageData(productName, new MemoryStream(data), ar => UsageDataUploaded(ar, client, commaSeparatedSessionIDList), null); } catch (CommunicationException) { // ignore error (maybe currently not connected to network) diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes.csproj b/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes.csproj new file mode 100644 index 0000000000..e10d619cae --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes.csproj @@ -0,0 +1,129 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {3836F4A8-4B35-4F5E-BB0F-DAD374297525} + library + Properties + AvalonDock.Themes + AvalonDock.Themes + v4.0 + Client + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {87E61430-4243-45F2-B74E-0A4C096CEBF3} + AvalonDock + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes.csproj.user b/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes.csproj.user new file mode 100644 index 0000000000..07dbd5b56e --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/AvalonDock.Themes.csproj.user @@ -0,0 +1,6 @@ + + + + ProjectFiles + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/Resources/images/HTabGroup.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/HTabGroup.png similarity index 100% rename from src/Libraries/AvalonDock/Resources/images/HTabGroup.png rename to src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/HTabGroup.png diff --git a/src/Libraries/AvalonDock/Resources/images/Locked.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/Locked.png similarity index 100% rename from src/Libraries/AvalonDock/Resources/images/Locked.png rename to src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/Locked.png diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinAutoHide.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinAutoHide.png new file mode 100644 index 0000000000..540c4a1bb7 Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinAutoHide.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinClose.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinClose.png new file mode 100644 index 0000000000..db99ae4888 Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinClose.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinDocMenu.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinDocMenu.png new file mode 100644 index 0000000000..b6be30f66b Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinDocMenu.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinMenu.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinMenu.png new file mode 100644 index 0000000000..653373ce5c Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/PinMenu.png differ diff --git a/src/Libraries/AvalonDock/Resources/images/VTabGroup.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/VTabGroup.png similarity index 100% rename from src/Libraries/AvalonDock/Resources/images/VTabGroup.png rename to src/Libraries/AvalonDock/AvalonDock.Themes/Images/ExpDark/VTabGroup.png diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/HTabGroup.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/HTabGroup.png new file mode 100644 index 0000000000..4c50d26d30 Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/HTabGroup.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/Locked.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/Locked.png new file mode 100644 index 0000000000..b8f6ced2df Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/Locked.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinAutoHide.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinAutoHide.png new file mode 100644 index 0000000000..abefd96b63 Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinAutoHide.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinClose.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinClose.png new file mode 100644 index 0000000000..132bdfafca Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinClose.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinDocMenu.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinDocMenu.png new file mode 100644 index 0000000000..b6be30f66b Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinDocMenu.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinMenu.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinMenu.png new file mode 100644 index 0000000000..653373ce5c Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/PinMenu.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/VTabGroup.png b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/VTabGroup.png new file mode 100644 index 0000000000..c3f279f7d7 Binary files /dev/null and b/src/Libraries/AvalonDock/AvalonDock.Themes/Images/dev2010/VTabGroup.png differ diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/AssemblyInfo.cs b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..b3c1476e11 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AvalonDock.Themes")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AvalonDock.Themes")] +[assembly: AssemblyCopyright("Copyright © Adolfo Marinucci 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..b1b282a8cf --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AvalonDock.Themes.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AvalonDock.Themes.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.resx b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.resx new file mode 100644 index 0000000000..af7dbebbac --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..57f26aa8b7 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AvalonDock.Themes.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.settings b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml new file mode 100644 index 0000000000..0bef6aafde --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/ExpressionDark.xaml @@ -0,0 +1,960 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml new file mode 100644 index 0000000000..1e1751be84 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.Themes/Themes/dev2010.xaml @@ -0,0 +1,1332 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Libraries/AvalonDock/AvalonDock.url b/src/Libraries/AvalonDock/AvalonDock.url new file mode 100644 index 0000000000..e7270f30c5 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,2 +[InternetShortcut] +URL=http://avalondock.codeplex.com/ +IDList= diff --git a/src/Libraries/AvalonDock/AlignedImage.cs b/src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs similarity index 98% rename from src/Libraries/AvalonDock/AlignedImage.cs rename to src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs index a41303b2d9..ecafc7182f 100644 --- a/src/Libraries/AvalonDock/AlignedImage.cs +++ b/src/Libraries/AvalonDock/AvalonDock/AlignedImage.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -36,14 +36,11 @@ namespace AvalonDock { public class AlignedImage : Decorator { - /* - * Disabled because we use WPF 4.0 layout rounding instead. public AlignedImage() { this.LayoutUpdated += new EventHandler(OnLayoutUpdated); } - protected override System.Windows.Size MeasureOverride(Size constraint) { Size desideredSize = new Size(); @@ -185,6 +182,6 @@ namespace AvalonDock double delta = value1 - value2; return ((delta < 1.53E-06) && (delta > -1.53E-06)); } - */ + } } diff --git a/src/Libraries/AvalonDock/AvalonDock.csproj b/src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj similarity index 56% rename from src/Libraries/AvalonDock/AvalonDock.csproj rename to src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj index 728cea778f..463c98c348 100644 --- a/src/Libraries/AvalonDock/AvalonDock.csproj +++ b/src/Libraries/AvalonDock/AvalonDock/AvalonDock.csproj @@ -1,41 +1,47 @@ - + + Debug AnyCPU - {2FF700C2-A38A-48BD-A637-8CAFD4FE6237} - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 8.0.30703 + 2.0 + {87E61430-4243-45F2-B74E-0A4C096CEBF3} + Library + Properties AvalonDock AvalonDock + v4.0 + Client + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 - library - 1.0.0.* - - 3.0 - v4.0 - - - 2.0 - - - true - AvalonDock.snk - C:\Users\Daniel\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis - ..\..\..\bin\ + False + File + ..\..\..\..\bin\ False False - False + false true Full false DEBUG;TRACE + prompt + 4 - false + pdbonly true TRACE - None + prompt + 4 + + + true + + + AvalonDock.snk False @@ -45,212 +51,211 @@ Auto 4194304 AnyCPU - 4096 - - 3.5 - - - 3.0 - - - 3.0 - - - 3.0 - - - 3.0 - - - - - 3.0 - + + + + 4.0 + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Designer - Resources.Designer.cs - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - True - Resources.resx - - - True - True - Settings.settings - + + + + + + + + + + + + + - + + + - - - - - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile + Designer - Designer MSBuild:Compile - - Designer - MSBuild:Compile - - Designer + MSBuild:Compile + Designer - + MSBuild:Compile Designer - + MSBuild:Compile Designer - + MSBuild:Compile Designer - + + MSBuild:Compile Designer + + + + + + + MSBuild:Compile + Designer - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + - - + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - - - - - + + + + + + - + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock.snk b/src/Libraries/AvalonDock/AvalonDock/AvalonDock.snk similarity index 100% rename from src/Libraries/AvalonDock/AvalonDock.snk rename to src/Libraries/AvalonDock/AvalonDock/AvalonDock.snk diff --git a/src/Libraries/AvalonDock/AvalonDockBrushes.cs b/src/Libraries/AvalonDock/AvalonDock/AvalonDockBrushes.cs similarity index 74% rename from src/Libraries/AvalonDock/AvalonDockBrushes.cs rename to src/Libraries/AvalonDock/AvalonDock/AvalonDockBrushes.cs index 20938b4fd0..34d7c98e4d 100644 --- a/src/Libraries/AvalonDock/AvalonDockBrushes.cs +++ b/src/Libraries/AvalonDock/AvalonDock/AvalonDockBrushes.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -81,19 +81,51 @@ namespace AvalonDock DocumentHeaderForeground, /// - /// Brush used for the background of a document header when active (). + /// Brush used for fonts while a document header is selected but not activated + /// + DocumentHeaderForegroundSelected, + + /// + /// Brush used for fonts while a document header is selected and activated + /// + DocumentHeaderForegroundSelectedActivated, + + /// + /// Brush used for the background of a document header when selected (). /// DocumentHeaderBackgroundSelected, + /// + /// Brush used for the background of a document header when active and selected (). + /// + DocumentHeaderBackgroundSelectedActivated, + /// /// Brush used for the background of a document header when mouse is over it. /// DocumentHeaderBackgroundMouseOver, + /// + /// Brush used for the border brush of a document header when mouse is over it (but is not selected). + /// + DocumentHeaderBorderBrushMouseOver, + /// + /// Brush for the document header border + /// DocumentHeaderBorder, - DocumentHeaderBorder2, + /// + /// Brush for the document header border when contains a document selected + /// + DocumentHeaderBorderSelected, + + /// + /// Brush for the document header border when contains a document selected and activated + /// + DocumentHeaderBorderSelectedActivated, + + NavigatorWindowTopBackground, diff --git a/src/Libraries/AvalonDock/AvalonDock/AvalonDockWindow.cs b/src/Libraries/AvalonDock/AvalonDock/AvalonDockWindow.cs new file mode 100644 index 0000000000..cf5fc169d5 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/AvalonDockWindow.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; + +namespace AvalonDock +{ + public class AvalonDockWindow : Window + { + static AvalonDockWindow() + { + ShowInTaskbarProperty.OverrideMetadata(typeof(AvalonDockWindow), new FrameworkPropertyMetadata(false)); + + } + + internal AvalonDockWindow() + { } + } +} diff --git a/src/Libraries/AvalonDock/ContextMenuElement.cs b/src/Libraries/AvalonDock/AvalonDock/ContextMenuElement.cs similarity index 87% rename from src/Libraries/AvalonDock/ContextMenuElement.cs rename to src/Libraries/AvalonDock/AvalonDock/ContextMenuElement.cs index 8644d57305..d607886ddc 100644 --- a/src/Libraries/AvalonDock/ContextMenuElement.cs +++ b/src/Libraries/AvalonDock/AvalonDock/ContextMenuElement.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -45,9 +45,14 @@ namespace AvalonDock DocumentPane, /// - /// Context menu related to a + /// Context menu related to a /// - FloatingWindow, + DockableFloatingWindow, + + /// + /// Context menu related to a + /// + DocumentFloatingWindow } } diff --git a/src/Libraries/AvalonDock/Converters.cs b/src/Libraries/AvalonDock/AvalonDock/Converters.cs similarity index 58% rename from src/Libraries/AvalonDock/Converters.cs rename to src/Libraries/AvalonDock/AvalonDock/Converters.cs index 8f9e498234..feae586935 100644 --- a/src/Libraries/AvalonDock/Converters.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Converters.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -31,32 +31,33 @@ using System.IO; using System.Reflection; using System.Windows.Media; using System.Windows; +using System.Windows.Controls; +using System.Windows.Media.Imaging; namespace AvalonDock { - public class FindResourcePathConverter : IValueConverter - { - - #region IValueConverter Members + //public class FindResourcePathConverter : IValueConverter + //{ + // #region IValueConverter Members - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - if (value == null) - { - return null; - //return new Uri(@"DocumentHS.png", UriKind.Relative); - } + // public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + // { + // if (value == null) + // { + // return null; + // //return new Uri(@"DocumentHS.png", UriKind.Relative); + // } - return value; - } + // return value; + // } - public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - throw new NotImplementedException(); - } + // public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + // { + // throw new NotImplementedException(); + // } - #endregion - } + // #endregion + //} /// /// Converter from boolean values to visibility (inverse mode) @@ -78,6 +79,59 @@ namespace AvalonDock } } + [ValueConversion(typeof(object), typeof(Image))] + public class ObjectToImageConverter : IValueConverter + { + + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + double width = 16.0; + if (parameter != null && + parameter is double) + width = (double)parameter; + + if (value is string) + { + Uri iconUri; + // try to resolve given value as an absolute URI + if (Uri.TryCreate(value as String, UriKind.RelativeOrAbsolute, out iconUri)) + { + var img = new BitmapImage(iconUri); + if (img != null) + { + return new Image() + { + UseLayoutRounding = true, + Width = width, + Source = img + }; + } + } + } + else if (value is BitmapImage) + { + var img = value as BitmapImage; + return new Image() + { + UseLayoutRounding = true, + Width = width, + Source = new BitmapImage(img.UriSource) + }; + + } + + return value; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + + #endregion + } public static class Converters { @@ -94,6 +148,20 @@ namespace AvalonDock return _BoolToVisibilityConverter; } } + + static ObjectToImageConverter _ObjectToImageConverter = null; + + public static ObjectToImageConverter ObjectToImageConverter + { + get + { + if (_ObjectToImageConverter == null) + _ObjectToImageConverter = new ObjectToImageConverter(); + + + return _ObjectToImageConverter; + } + } } } diff --git a/src/Libraries/AvalonDock/DeserializationCallbackEventArgs.cs b/src/Libraries/AvalonDock/AvalonDock/DeserializationCallbackEventArgs.cs similarity index 91% rename from src/Libraries/AvalonDock/DeserializationCallbackEventArgs.cs rename to src/Libraries/AvalonDock/AvalonDock/DeserializationCallbackEventArgs.cs index cc8acf2248..8ebc85087f 100644 --- a/src/Libraries/AvalonDock/DeserializationCallbackEventArgs.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DeserializationCallbackEventArgs.cs @@ -20,6 +20,6 @@ namespace AvalonDock /// /// Gets/Sets the content manually deserialized /// - public DockableContent Content { get; set; } + public ManagedContent Content { get; set; } } } diff --git a/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs b/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs new file mode 100644 index 0000000000..ecbec60d80 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DockableContent.cs @@ -0,0 +1,954 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.Diagnostics; +using System.Xml; +using System.ComponentModel; +using System.Linq; + +namespace AvalonDock +{ + /// + /// Enumerates all the possible states of + /// + public enum DockableContentState + { + /// + /// Content is not associated with any (Default State) + /// + None, + + /// + /// Content is docked to a border of a within as control + /// + Docked, + + /// + /// Content is hosted by a flyout window and is visible only when user move mouse over an anchor thumb located to a controlo border + /// + AutoHide, + + /// + /// Content is hosted by a floating window and user can redock is on its container control + /// + DockableWindow, + + /// + /// Content is hosted by a floating window that can't be docked to a its container control + /// + FloatingWindow, + + /// + /// Content is hosted into a + /// + Document, + + /// + /// Content is hidden + /// + Hidden, + } + + + /// + /// Defines how a dockable content can be dragged over a docking manager + /// + /// This style can be composed with the 'or' operator. + public enum DockableStyle : uint + { + /// + /// Content is not dockable at all + /// + None = 0x0000, + + /// + /// Dockable as document + /// + Document = 0x0001, + + /// + /// Dockable to the left border of + /// + LeftBorder = 0x0002, + + /// + /// Dockable to the right border of + /// + RightBorder = 0x0004, + + /// + /// Dockable to the top border of + /// + TopBorder = 0x0008, + + /// + /// Dockable to the bottom border of + /// + BottomBorder= 0x0010, + + /// + /// A with this style can be hosted in a + /// + Floating = 0x0020, + + /// + /// A with this style can be the only one content in a pane (NOT YET SUPPORTED) + /// + /// This style is not compatible with style + Single = 0x0040, + + /// + /// A with this style can be autohidden. + /// + AutoHide = 0x0080, + + /// + /// Dockable only to a border of a + /// + DockableToBorders = LeftBorder | RightBorder | TopBorder | BottomBorder | AutoHide, + + /// + /// Dockable to a border of a and into a + /// + Dockable = DockableToBorders | Document | Floating, + + /// + /// Dockable to a border of a and into a but not in autohidden mode (WinForms controls) + /// + DockableButNotAutoHidden = Dockable & ~AutoHide + } + + + /// + /// Represent a state of a dockable content that can be used to restore it after it's hidden + /// + internal class DockableContentStateAndPosition + { + public readonly Pane ContainerPane = null; + public readonly Guid ContainerPaneID; + public readonly int ChildIndex = -1; + public readonly double Width; + public readonly double Height; + public readonly DockableContentState State; + public readonly AnchorStyle Anchor = AnchorStyle.None; + + public DockableContentStateAndPosition( + Pane containerPane, + int childIndex, + double width, + double height, + AnchorStyle anchor, + DockableContentState state) + { + ContainerPane = containerPane; + ChildIndex = childIndex; + Width = Math.Max(width, 100.0); + Height = Math.Max(height, 100.0); + Anchor = anchor; + State = state; + } + + public DockableContentStateAndPosition( + Guid containerPaneID, + int childIndex, + double width, + double height, + AnchorStyle anchor, + DockableContentState state) + { + ContainerPaneID = containerPaneID; + ChildIndex = childIndex; + Width = Math.Max(width, 100.0); + Height = Math.Max(height, 100.0); + Anchor = anchor; + State = state; + } + + public DockableContentStateAndPosition( + DockableContent cntToSave) + { + ContainerPane = cntToSave.ContainerPane; + ChildIndex = ContainerPane.Items.IndexOf(cntToSave); + Width = Math.Max(ContainerPane.ActualWidth, 100.0); + Height = Math.Max(ContainerPane.ActualHeight, 100.0); + State = cntToSave.State; + + DockablePane dockablePane = ContainerPane as DockablePane; + if (dockablePane != null) + { + Anchor = dockablePane.Anchor; + } + } + } + + /// + /// Identifies a content that can be drag over a control or hosted by a window floating over it (). + /// + public class DockableContent : ManagedContent + { + static DockableContent() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DockableContent), new FrameworkPropertyMetadata(typeof(DockableContent))); + } + + public DockableContent() + { + } + + protected override void OnContentLoaded() + { + //now the logical tree is up + DockingManager manager = GetParentManager(null); + + //if can't find the manager there is a problem + //if (manager == null) + // throw new InvalidOperationException("Unable to find DockingManager object in the logical tree"); + //if (manager != null) + // manager.DockableContents.Add(this); + + base.OnContentLoaded(); + } + + protected override void OnContentUnloaded() + { + //if (Manager != null && !Manager.HiddenContents.Contains(this)) + // Manager.DockableContents.Remove(this); + + base.OnContentUnloaded(); + } + + SizeToContent _floatingWindowSizeToContent = SizeToContent.Manual; + + /// + /// Gets or sets a value indicating if this dockable content should change the size of a FloatingWindow when undocked + /// + public SizeToContent FloatingWindowSizeToContent + { + get { return _floatingWindowSizeToContent; } + set + { + _floatingWindowSizeToContent = value; + RaisePropertyChanged("FloatingWindowSizeToContent"); + } + } + + #region Drag content + protected override void OnDragMouseMove(object sender, MouseEventArgs e) + { + base.OnDragMouseMove(sender, e); + } + + protected override void OnDragStart(Point ptMouse, Point ptRelativeMouse) + { + if (DockableStyle != DockableStyle.None && + (State == DockableContentState.Docked || State == DockableContentState.Document || State == DockableContentState.DockableWindow) && + !Manager.DragPaneServices.IsDragging) + { + Manager.Drag(this, HelperFunc.PointToScreenWithoutFlowDirection(this, ptMouse), ptRelativeMouse); + } + + base.OnDragStart(ptMouse, ptRelativeMouse); + } + + #endregion + + #region State Properties & Events + + #region StateChanged + + /// + /// StateChanged Routed Event + /// + public static readonly RoutedEvent StateChangedEvent = EventManager.RegisterRoutedEvent("StateChanged", + RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DockableContent)); + + /// + /// Occurs when State property changes + /// + public event RoutedEventHandler StateChanged + { + add { AddHandler(StateChangedEvent, value); } + remove { RemoveHandler(StateChangedEvent, value); } + } + + /// + /// A helper method to raise the StateChanged event. + /// + protected RoutedEventArgs RaiseStateChangedEvent() + { + return RaiseStateChangedEvent(this); + } + + /// + /// A static helper method to raise the StateChanged event on a target element. + /// + /// UIElement or ContentElement on which to raise the event + static RoutedEventArgs RaiseStateChangedEvent(DependencyObject target) + { + if (target == null) return null; + + RoutedEventArgs args = new RoutedEventArgs(); + args.RoutedEvent = StateChangedEvent; + RoutedEventHelper.RaiseEvent(target, args); + return args; + } + + #endregion + + /// + /// Gets the state of + /// + public DockableContentState State + { + get { return (DockableContentState)GetValue(StatePropertyKey.DependencyProperty); } + protected set { SetValue(StatePropertyKey, value); } + } + + // Using a DependencyProperty as the backing store for State. This enables animation, styling, binding, etc... + public static readonly DependencyPropertyKey StatePropertyKey = + DependencyProperty.RegisterReadOnly("State", + typeof(DockableContentState), + typeof(DockableContent), + new FrameworkPropertyMetadata( + DockableContentState.None, + new PropertyChangedCallback( + (s, e) => + { + ((DockableContent)s).OnStateChanged((DockableContentState)e.OldValue, (DockableContentState)e.NewValue); + } + ))); + + protected virtual void OnStateChanged(DockableContentState oldState, DockableContentState newState) + { + RaiseStateChangedEvent(this); + + if (ContainerPane is DockablePane) + ((DockablePane)ContainerPane).UpdateCanAutohideProperty(); + } + + public static readonly DependencyProperty StateProperty = + StatePropertyKey.DependencyProperty; + + #region DockableStyle + + /// + /// DockableStyle Dependency Property + /// + public static readonly DependencyProperty DockableStyleProperty = + DependencyProperty.Register("DockableStyle", typeof(DockableStyle), typeof(DockableContent), + new FrameworkPropertyMetadata(DockableStyle.Dockable)); + + /// + /// Get or sets a value that indicates how a dockable content can be dragged over and docked to a + /// + public DockableStyle DockableStyle + { + get { return (DockableStyle)GetValue(DockableStyleProperty); } + set { SetValue(DockableStyleProperty, value); } + } + + #endregion + + + + + protected override void OnVisualParentChanged(DependencyObject oldParent) + { + + base.OnVisualParentChanged(oldParent); + + //if (oldParent == null && State == DockableContentState.None) + //{ + // if (Parent is FloatingDockablePane) + // { + // throw new InvalidOperationException(); + // } + + // SetStateToDock(); + //} + + } + + + #endregion + + #region StateMachine + + internal void SetStateToAutoHide() + { + State = DockableContentState.AutoHide; + } + + internal void SetStateToDock() + { + State = DockableContentState.Docked; + } + + internal void SetStateToDockableWindow() + { + if (State == DockableContentState.DockableWindow) + return; + + Debug.Assert( + State == DockableContentState.None || + State == DockableContentState.Document || + State == DockableContentState.Docked || + State == DockableContentState.FloatingWindow || + State == DockableContentState.Hidden); + + State = DockableContentState.DockableWindow; + } + + internal void SetStateToFloatingWindow() + { + if (State == DockableContentState.FloatingWindow) + return; + + Debug.Assert( + State == DockableContentState.Document || + State == DockableContentState.Docked || + State == DockableContentState.DockableWindow); + + State = DockableContentState.FloatingWindow; + } + + internal void SetStateToHidden() + { + State = DockableContentState.Hidden; + } + + internal void SetStateToDocument() + { + State = DockableContentState.Document; + } + #endregion + + #region HideOnClose + public static DependencyProperty HideOnCloseKey = DependencyProperty.Register("HideOnClose", typeof(bool), typeof(DockableContent), new PropertyMetadata(true)); + + public bool HideOnClose + { + get { return (bool)GetValue(HideOnCloseKey); } + set { SetValue(HideOnCloseKey, value); } + } + #endregion + + //#region OnIsActiveContentChanged (flyout windows) + //protected override void OnIsActiveContentChanged(DependencyPropertyChangedEventArgs e) + //{ + // if (State == DockableContentState.AutoHide) + // Manager.ShowFlyoutWindow(this, null); + + // base.OnIsActiveContentChanged(e); + //} + //#endregion + + protected override void OnInitialized(EventArgs e) + { + base.OnInitialized(e); + + this.CommandBindings.Add( + new CommandBinding(DockableContentCommands.FloatingWindow, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DockableContentCommands.DockableFloatingWindow, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(ManagedContentCommands.Show, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DockableContentCommands.ShowAsDocument, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DockableContentCommands.ToggleAutoHide, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(ManagedContentCommands.Hide, this.OnExecuteCommand, this.OnCanExecuteCommand)); + } + + #region Commands + + void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + { + if (!e.Handled && + e.Command == DockableContentCommands.ToggleAutoHide) + { + ToggleAutoHide(); + + e.Handled = true; + } + else if (!e.Handled && e.Command == DockableContentCommands.FloatingWindow) + { + ShowAsFloatingWindow(false); + + e.Handled = true; + } + else if (!e.Handled && e.Command == DockableContentCommands.DockableFloatingWindow) + { + ShowAsFloatingWindow(true); + + e.Handled = true; + } + else if (!e.Handled && e.Command == DockableContentCommands.ShowAsDocument) + { + ShowAsDocument(); + e.Handled = true; + } + } + + void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = CanExecuteCommand(e.Command); + } + + /// + /// Show as docked pane + /// + public override void Show() + { + Show(Manager); + } + + /// + /// Show as docked pane within provided + /// + public override void Show(DockingManager manager) + { + if (SavedStateAndPosition != null && State == DockableContentState.Hidden) + Show(manager, SavedStateAndPosition.Anchor); + else + Show(manager, AnchorStyle.None); + } + + /// + /// Show as docked pane + /// + /// Desidered anchor position + public void Show(AnchorStyle desideredAnchor) + { + Show(Manager, desideredAnchor); + } + + /// + /// Show as docked pane + /// + public void Show(DockingManager manager, AnchorStyle desideredAnchor) + { + if (Manager != null && Manager != manager) + throw new InvalidOperationException("Please remove the content from previous DockingManager (using the Close method)"); + + if (manager == null && !CanExecuteCommand(ManagedContentCommands.Show)) + throw new InvalidOperationException("This operation can be executed in this state"); + + if (State == DockableContentState.Docked) + { + //if already shown as docked content just activate it + Activate(); + } + else + { + if (SavedStateAndPosition != null && State == DockableContentState.Hidden) + manager.Show(this, SavedStateAndPosition.State, desideredAnchor); + else + manager.Show(this, DockableContentState.Docked, desideredAnchor); + } + } + + /// + /// Show as as a tabbed document + /// + public void ShowAsDocument() + { + ShowAsDocument(Manager); + } + + /// + /// Show as as a tabbed document under the provided + /// + public void ShowAsDocument(DockingManager manager) + { + if (Manager != null && Manager != manager) + throw new InvalidOperationException("Please remove the content from previous DockingManager (using the Close method)"); + + //Manager = manager; + + if (manager == null && !CanExecuteCommand(DockableContentCommands.ShowAsDocument)) + throw new InvalidOperationException("This operation can be executed in this state"); + + manager.Show(this, DockableContentState.Document); + } + + /// + /// Show the content as floating window inside the provided + /// + /// True if the resulting floating window can the be re-docked to the docking manager. + public void ShowAsFloatingWindow(bool dockableWindow) + { + ShowAsFloatingWindow(Manager, dockableWindow); + } + + /// + /// Show the content ad floating window + /// + /// True if the resulting floating window can the be re-docked to the docking manager. + public void ShowAsFloatingWindow(DockingManager manager, bool dockableWindow) + { + if (Manager != null && Manager != manager) + throw new InvalidOperationException("Please remove the content from previous DockingManager (using the Close method)"); + + //Manager = manager; + + if (manager == null) + { + if (dockableWindow && + !CanExecuteCommand(DockableContentCommands.DockableFloatingWindow)) + throw new InvalidOperationException("This operation can be executed in this state"); + if (!dockableWindow && + !CanExecuteCommand(DockableContentCommands.FloatingWindow)) + throw new InvalidOperationException("This operation can be executed in this state"); + } + + manager.Show(this, dockableWindow ? DockableContentState.DockableWindow : DockableContentState.FloatingWindow); + } + + + /// + /// Hides this content + /// + public override bool Hide() + { + if (!CanExecuteCommand(ManagedContentCommands.Hide)) + return false; + + Manager.Hide(this); + return true; + } + + /// + /// Close content + /// + public override bool Close() + { + return CloseOrHide(); + } + + /// + /// Close content + /// + /// If true forces the content closing regardless of the property. + public bool Close(bool forceClose) + { + return CloseOrHide(true); + } + + /// + /// Closes or hides provided content depending on HideOnClose property + /// + internal virtual bool CloseOrHide() + { + return CloseOrHide(false); + } + + /// + /// Closes or hides content depending on HideOnClose property + /// + internal virtual bool CloseOrHide(bool force) + { + if (!force && + !IsCloseable) + return false; + + if (HideOnClose) + { + Hide(); + return true; + } + else + { + if (!CanExecuteCommand(ManagedContentCommands.Close)) + throw new InvalidOperationException("This operation can be executed in this state"); + + CancelEventArgs e = new CancelEventArgs(false); + OnClosing(e); + + if (e.Cancel) + return false; + + DockingManager oldManager = Manager; + + if (e.Cancel) + return false; + + ((DockablePane)ContainerPane).RemoveContent( + ContainerPane.Items.IndexOf(this)); + + OnClosed(); + return true; + } + } + + /// + /// Slides out this content to a border of the containing docking manager + /// + public void ToggleAutoHide() + { + if (!CanExecuteCommand(DockableContentCommands.ToggleAutoHide)) + throw new InvalidOperationException("This operation can be executed in this state"); + + (ContainerPane as DockablePane).ToggleAutoHide(); + } + + public override void Activate() + { + if (State == DockableContentState.AutoHide) + { + if (Manager != null && this.IsLoaded) + { + Manager.ShowFlyoutWindow(this, null); + } + } + else if (State == DockableContentState.Document) + { + if (!DocumentTabPanel.GetIsHeaderVisible(this)) + { + DocumentPane parentPane = this.ContainerPane as DocumentPane; + if (parentPane != null && + parentPane.GetManager() != null && + parentPane.Items.IndexOf(this) != 0) + { + parentPane.Items.Remove(this); + parentPane.Items.Insert(0, this); + parentPane.SelectedIndex = 0; + } + } + } + base.Activate(); + } + + /// + /// Retrive a value indicating if the command can be executed based to the dockable content state + /// + /// + /// + protected override bool CanExecuteCommand(ICommand command) + { + //if (State == DockableContentState.None) + // return false; + + if (command == ManagedContentCommands.Hide) + { + if (State == DockableContentState.Hidden) + { + return false; + } + } + else if (command == DockableContentCommands.ShowAsDocument) + { + if (State == DockableContentState.Document) + { + return false; + } + } + else if (command == DockableContentCommands.FloatingWindow) + { + if (State == DockableContentState.FloatingWindow || + State == DockableContentState.DockableWindow) + { + return false; + } + } + else if (command == DockableContentCommands.ToggleAutoHide) + { + if (State == DockableContentState.AutoHide || + State == DockableContentState.Document || + State == DockableContentState.FloatingWindow || + State == DockableContentState.DockableWindow) + { + return false; + } + } + else if (command == DockableContentCommands.ShowAsDocument) + { + if (State == DockableContentState.Document) + { + return false; + } + } + else if (command == DockableContentCommands.DockableFloatingWindow) + { + if (State == DockableContentState.FloatingWindow || + State == DockableContentState.DockableWindow) + { + return false; + } + } + else if (command == ManagedContentCommands.Show) + { + if (State == DockableContentState.Docked) + { + return false; + } + } + + return base.CanExecuteCommand(command); + } + #endregion + + #region Operations on content + + + + + DockableContentStateAndPosition _savedStateAndPosition = null; + + internal DockableContentStateAndPosition SavedStateAndPosition + { + get { return _savedStateAndPosition; } + set { _savedStateAndPosition = value; } + } + + internal void SaveCurrentStateAndPosition() + { + SavedStateAndPosition = new DockableContentStateAndPosition( + this); + } + + /// + /// Reset internal state and position of the content + /// + /// After a is hidden AvalonDock save its state and position in order to + /// restore it correctly when user wants to reshow it calling function. Call this method + /// if you want to reset these data and provide your state and anchor style calling one of the overloads of the function + /// . + public void ResetSavedStateAndPosition() + { + SavedStateAndPosition = null; + } + + #endregion + + #region Save/Restore Content Layout + /// + /// Save content specific layout settings + /// + /// Backend store writer + /// Custom derived class can overloads this method to handle custom layout persistence. + public override void SaveLayout(XmlWriter storeWriter) + { + if (!FloatingWindowSize.IsEmpty) + { + storeWriter.WriteAttributeString( + "FloatingWindowSize", new SizeConverter().ConvertToInvariantString(FloatingWindowSize)); + } + + if (SavedStateAndPosition != null) + { + storeWriter.WriteAttributeString( + "ChildIndex", SavedStateAndPosition.ChildIndex.ToString()); + storeWriter.WriteAttributeString( + "Width", SavedStateAndPosition.Width.ToString()); + storeWriter.WriteAttributeString( + "Height", SavedStateAndPosition.Height.ToString()); + storeWriter.WriteAttributeString( + "Anchor", SavedStateAndPosition.Anchor.ToString()); + storeWriter.WriteAttributeString( + "State", SavedStateAndPosition.State.ToString()); + + if (SavedStateAndPosition.ContainerPane is DockablePane) + { + Guid idToSave = (SavedStateAndPosition.ContainerPane as DockablePane).ID; + storeWriter.WriteAttributeString( + "ContainerPaneID", idToSave.ToString()); + } + } + + } + + /// + /// Restore content specific layout settings + /// + /// Saved xml element containg content layout settings + /// Custom derived class must overload this method to restore custom layout settings previously saved trought . + public override void RestoreLayout(XmlElement contentElement) + { + if (contentElement.HasAttribute("FloatingWindowSize")) + FloatingWindowSize = (Size)(new SizeConverter()).ConvertFromInvariantString(contentElement.GetAttribute("FloatingWindowSize")); + + Size effectiveSize = new Size(0d, 0d); + if (contentElement.HasAttribute("EffectiveSize")) + { + // Store + effectiveSize = (Size)(new SizeConverter()).ConvertFromInvariantString(contentElement.GetAttribute("EffectiveSize")); + } + + ResizingPanel.SetEffectiveSize(this, effectiveSize); + + if (contentElement.HasAttribute("ChildIndex")) + { + Pane paneRef = null; + Guid containerPaneGuid = Guid.Empty; + if (contentElement.HasAttribute("ContainerPaneID")) + { + containerPaneGuid = Guid.Parse(contentElement.GetAttribute("ContainerPaneID")); + + if (Manager != null) + { + ILinqToTree itemFound = new LogicalTreeAdapter(Manager).Descendants().FirstOrDefault(el => el.Item is DockablePane && ((el.Item as DockablePane).ID == containerPaneGuid)); + paneRef = itemFound != null ? itemFound.Item as DockablePane : null; + } + } + + if (paneRef != null) + { + _savedStateAndPosition = new DockableContentStateAndPosition( + paneRef, + int.Parse(contentElement.GetAttribute("ChildIndex")), + double.Parse(contentElement.GetAttribute("Width")), + double.Parse(contentElement.GetAttribute("Height")), + (AnchorStyle)Enum.Parse(typeof(AnchorStyle), contentElement.GetAttribute("Anchor")), + (DockableContentState)Enum.Parse(typeof(DockableContentState), contentElement.GetAttribute("State"))); + } + else + { + _savedStateAndPosition = new DockableContentStateAndPosition( + containerPaneGuid, + int.Parse(contentElement.GetAttribute("ChildIndex")), + double.Parse(contentElement.GetAttribute("Width")), + double.Parse(contentElement.GetAttribute("Height")), + (AnchorStyle)Enum.Parse(typeof(AnchorStyle), contentElement.GetAttribute("Anchor")), + (DockableContentState)Enum.Parse(typeof(DockableContentState), contentElement.GetAttribute("State"))); + } + } + } + #endregion + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/DockableContentCommands.cs b/src/Libraries/AvalonDock/AvalonDock/DockableContentCommands.cs new file mode 100644 index 0000000000..5a0ae4fed6 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DockableContentCommands.cs @@ -0,0 +1,128 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + /// + /// Defines commands that can be executed against a DockableContent + /// + public sealed class DockableContentCommands + { + static object syncRoot = new object(); + + private static RoutedUICommand documentCommand = null; + + /// + /// Shows the DockableContent as a tabbed document + /// + public static RoutedUICommand ShowAsDocument + { + get + { + lock (syncRoot) + { + if (null == documentCommand) + { + documentCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockableContentCommands_ShowAsDocument, "Document", typeof(DockableContentCommands)); + } + } + return documentCommand; + } + } + + + private static RoutedUICommand floatingWindowCommand = null; + + /// + /// Shows the as a which overlays the + /// + /// A floating window can't be redocked to the docking manager. + public static RoutedUICommand FloatingWindow + { + get + { + lock (syncRoot) + { + if (null == floatingWindowCommand) + { + floatingWindowCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockableContentCommands_FloatingWindow, "FloatingWindow", typeof(DockableContentCommands)); + } + } + return floatingWindowCommand; + } + } + + private static RoutedUICommand dockableWindowCommand = null; + + /// + /// Shows the as a which overlays the + /// + /// A floating window can't be redocked to the docking manager. + public static RoutedUICommand DockableFloatingWindow + { + get + { + lock (syncRoot) + { + if (null == dockableWindowCommand) + { + dockableWindowCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockableContentCommands_DockableFloatingWindow, "DockableFloatingWindow", typeof(DockableContentCommands)); + } + } + return dockableWindowCommand; + } + } + + private static RoutedUICommand autoHideCommand = null; + + /// + /// Switch the state of a from to and viceversa + /// + /// This command has the same effect as applying command to container pane + public static RoutedUICommand ToggleAutoHide + { + get + { + lock (syncRoot) + { + if (null == autoHideCommand) + { + autoHideCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockableContentCommands_ToggleAutoHide, "AutoHide", typeof(DockableContentCommands)); + } + } + return autoHideCommand; + } + } + + + + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs b/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs new file mode 100644 index 0000000000..be1fc8fdd1 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindow.cs @@ -0,0 +1,303 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Markup; +using System.Diagnostics; +using System.Windows.Threading; +using System.Windows.Media.Animation; +using System.Windows.Interop; +using System.Linq; + +namespace AvalonDock +{ + public class DockableFloatingWindow : FloatingWindow + { + static DockableFloatingWindow() + { + //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. + //This style is defined in themes\generic.xaml + DefaultStyleKeyProperty.OverrideMetadata(typeof(DockableFloatingWindow), new FrameworkPropertyMetadata(typeof(DockableFloatingWindow))); + + ContentControl.ContentProperty.OverrideMetadata(typeof(DockableFloatingWindow), + new FrameworkPropertyMetadata( + new PropertyChangedCallback(OnContentPropertyChanged), + new CoerceValueCallback(OnCoerceValueContentProperty))); + } + + //Pane _previousPane = null; + + //int _arrayIndexPreviousPane = -1; + + + internal DockableFloatingWindow(DockingManager manager) + : base(manager) + { + if (manager == null) + throw new ArgumentNullException("manager"); + } + + + //protected override void OnClosed(EventArgs e) + //{ + // base.OnClosed(e); + + // DockableContent[] cntsToClose = new DockableContent[HostedPane.Items.Count]; + // HostedPane.Items.CopyTo(cntsToClose, 0); + + // foreach (DockableContent cntToClose in cntsToClose) + // { + // //HostedPane.CloseOrHide(HostedPane.Items[0] as DockableContent, ForcedClosing); + // cntToClose.CloseOrHide(ForcedClosing); + // } + + // Manager.UnregisterFloatingWindow(this); + //} + + public override Pane ClonePane() + { + DockablePane paneToAnchor = new DockablePane(); + + ResizingPanel.SetEffectiveSize(paneToAnchor, new Size(Width, Height)); + + //if (HostedPane.Style != null) + // paneToAnchor.Style = HostedPane.Style; + + int selectedIndex = HostedPane.SelectedIndex; + + //transfer contents from hosted pane in the floating window and + //the new created dockable pane + while (HostedPane.Items.Count > 0) + { + paneToAnchor.Items.Add( + HostedPane.RemoveContent(0)); + } + + paneToAnchor.SelectedIndex = selectedIndex; + + return paneToAnchor; + } + + #region IsDockableWindow + + /// + /// IsDockableWindow Dependency Property + /// + public static readonly DependencyProperty IsDockableWindowProperty = + DependencyProperty.Register("IsDockableWindow", typeof(bool), typeof(DockableFloatingWindow), + new FrameworkPropertyMetadata(true, + new PropertyChangedCallback(OnIsDockableWindowChanged))); + + /// + /// Gets or sets the IsDockableWindow property. This dependency property + /// indicates that can be docked to . + /// + public bool IsDockableWindow + { + get { return (bool)GetValue(IsDockableWindowProperty); } + set { SetValue(IsDockableWindowProperty, value); } + } + + /// + /// Handles changes to the IsDockableWindow property. + /// + private static void OnIsDockableWindowChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((DockableFloatingWindow)d).OnIsDockableWindowChanged(e); + } + + /// + /// Provides derived classes an opportunity to handle changes to the IsDockableWindow property. + /// + protected virtual void OnIsDockableWindowChanged(DependencyPropertyChangedEventArgs e) + { + if ((bool)e.NewValue) + { + foreach (DockableContent content in HostedPane.Items) + content.SetStateToDockableWindow(); + } + else + { + foreach (DockableContent content in HostedPane.Items) + content.SetStateToFloatingWindow(); + } + } + + #endregion + + #region Commands + + protected virtual void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + { + if (e.Command == DockableFloatingWindowCommands.SetAsDockableWindow) + { + IsDockableWindow = true; + e.Handled = true; + } + else if (e.Command == DockableFloatingWindowCommands.SetAsFloatingWindow) + { + IsDockableWindow = false; + e.Handled = true; + } + } + + protected virtual void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + { + if (e.Command == DockableFloatingWindowCommands.SetAsDockableWindow) + e.CanExecute = !IsDockableWindow; + else if (e.Command == DockableFloatingWindowCommands.SetAsFloatingWindow) + e.CanExecute = IsDockableWindow; + } + #endregion + + protected override void OnInitialized(EventArgs e) + { + this.CommandBindings.Add(new CommandBinding(DockableFloatingWindowCommands.SetAsDockableWindow, OnExecuteCommand, OnCanExecuteCommand)); + this.CommandBindings.Add(new CommandBinding(DockableFloatingWindowCommands.SetAsFloatingWindow, OnExecuteCommand, OnCanExecuteCommand)); + + base.OnInitialized(e); + } + + protected override bool OpenContextMenu(UIElement popupButton, Point ptMouse) + { + ContextMenu cxMenu = FindResource(new ComponentResourceKey(typeof(DockingManager), + ContextMenuElement.DockableFloatingWindow)) as ContextMenu; + if (cxMenu != null) + { + foreach (var menuItem in cxMenu.Items.OfType()) + menuItem.CommandTarget = HostedPane.SelectedItem as IInputElement; + + if (popupButton != null) + { + cxMenu.Placement = PlacementMode.Bottom; + cxMenu.PlacementTarget = popupButton; + } + else + { + cxMenu.Placement = PlacementMode.Bottom; + cxMenu.PlacementRectangle = new Rect(ptMouse, new Size(0, 0)); + } + cxMenu.IsOpen = true; + + return true; + } + + return base.OpenContextMenu(popupButton, ptMouse); + } + + protected override void FilterMessage(object sender, FilterMessageEventArgs e) + { + e.Handled = false; + + if (Manager == null) + return; + + switch (e.Msg) + { + case WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager + if (IsDockableWindow && e.WParam.ToInt32() == HTCAPTION) + { + short x = (short)((e.LParam.ToInt32() & 0xFFFF)); + short y = (short)((e.LParam.ToInt32() >> 16)); + + Point clickPoint = this.TransformToDeviceDPI(new Point(x, y)); + Manager.Drag(this, clickPoint, new Point(clickPoint.X - Left, clickPoint.Y - Top)); + + e.Handled = true; + } + break; + case WM_NCLBUTTONDBLCLK: //Left Button Double Click -> dock to docking manager + if (IsDockableWindow && e.WParam.ToInt32() == HTCAPTION) + { + if (IsDockableWindow) + { + Dock(); + e.Handled = true; + } + } + break; + } + + + + base.FilterMessage(sender, e); + } + + static void OnContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + + } + + static object OnCoerceValueContentProperty(DependencyObject d, object baseValue) + { + DockableFloatingWindow fl = ((DockableFloatingWindow)d); + + if (fl.Content != null) + { + throw new InvalidOperationException("Content on floating windows can't be set more than one time."); + } + + if (!(baseValue is DockableContent) && + !(baseValue is DockablePane)) + { + throw new InvalidOperationException("Content must be of type DockableContent or DockablePane"); + } + + FloatingDockablePane paneToReturn = null; + + if (baseValue is DockableContent) + paneToReturn = new FloatingDockablePane(fl, baseValue as DockableContent); + else if (baseValue is DockablePane) + paneToReturn = new FloatingDockablePane(fl, baseValue as DockablePane); + + return paneToReturn; + } + + + public override void Dock() + { + var dockablePane = HostedPane as FloatingDockablePane; + + Debug.Assert(dockablePane != null); + + if (dockablePane != null) + dockablePane.Dock(); + + base.Dock(); + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindowCommands.cs b/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindowCommands.cs new file mode 100644 index 0000000000..858d9c6c48 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DockableFloatingWindowCommands.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + /// + /// Encapsulates the + /// + public sealed class DockableFloatingWindowCommands + { + private static object syncRoot = new object(); + + private static RoutedUICommand dockableCommand = null; + public static RoutedUICommand SetAsDockableWindow + { + get + { + lock (syncRoot) + { + if (null == dockableCommand) + { + dockableCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockableContentCommands_DockableFloatingWindow, "DockableWindow", typeof(DockableFloatingWindowCommands)); + } + } + return dockableCommand; + } + } + + private static RoutedUICommand floatingCommand = null; + public static RoutedUICommand SetAsFloatingWindow + { + get + { + lock (syncRoot) + { + if (null == floatingCommand) + { + floatingCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockableContentCommands_FloatingWindow, "FloatingWindow", typeof(DockableFloatingWindowCommands)); + } + } + return floatingCommand; + } + } + + //private static RoutedUICommand closeCommand = null; + //public static RoutedUICommand Close + //{ + // get + // { + // lock (syncRoot) + // { + // if (null == closeCommand) + // { + // closeCommand = new RoutedUICommand("Close", "Close", typeof(FloatingWindowCommands)); + // } + // } + // return closeCommand; + // } + //} + + //private static RoutedUICommand dockCommand = null; + //public static RoutedUICommand Dock + //{ + // get + // { + // lock (syncRoot) + // { + // if (null == dockCommand) + // { + // dockCommand = new RoutedUICommand("Dock", "Dock", typeof(FloatingWindowCommands)); + // } + // } + // return dockCommand; + // } + //} + } +} diff --git a/src/Libraries/AvalonDock/DockablePane.cs b/src/Libraries/AvalonDock/AvalonDock/DockablePane.cs similarity index 50% rename from src/Libraries/AvalonDock/DockablePane.cs rename to src/Libraries/AvalonDock/AvalonDock/DockablePane.cs index d0188c7d57..9f148670fb 100644 --- a/src/Libraries/AvalonDock/DockablePane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockablePane.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -38,7 +38,7 @@ using System.Windows.Shapes; using System.Diagnostics; using System.ComponentModel; using System.Collections; - +using System.Linq; namespace AvalonDock { @@ -70,6 +70,15 @@ namespace AvalonDock } + /// + /// Defines a pane that can contain contents of type + /// + /// Usually a is used to arrange a series of in TabControl like model. + /// A DockablePane can be redocked to a border of the parent , can be floated in an external window and can be autohidden. + /// When docked into a docking manager the property gives the border to which it's docked. + /// See to get commands that are supported by DockablePane objects. + /// + /// public class DockablePane : Pane { static DockablePane() @@ -79,47 +88,58 @@ namespace AvalonDock DefaultStyleKeyProperty.OverrideMetadata(typeof(DockablePane), new FrameworkPropertyMetadata(typeof(DockablePane))); } + public DockablePane() + { + this.Loaded += new RoutedEventHandler(DockablePane_Loaded); + this.Unloaded += new RoutedEventHandler(DockablePane_Unloaded); + + KeyboardNavigation.SetTabNavigation(this, KeyboardNavigationMode.Cycle); + } + protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); this.CommandBindings.Add( - new CommandBinding(ShowOptionsCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); - this.CommandBindings.Add( - new CommandBinding(ToggleAutoHideCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); + new CommandBinding(DockablePaneCommands.ToggleAutoHide, this.OnExecuteCommand, this.OnCanExecuteCommand)); this.CommandBindings.Add( - new CommandBinding(CloseCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); + new CommandBinding(DockablePaneCommands.Close, this.OnExecuteCommand, this.OnCanExecuteCommand)); } - public DockablePane() + protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { - this.Loaded += new RoutedEventHandler(DockablePane_Loaded); - this.Unloaded += new RoutedEventHandler(DockablePane_Unloaded); + if (e.NewItems != null) + { + e.NewItems.Cast().ForEach(c => + { + if (c.State == DockableContentState.None) + c.SetStateToDock(); + }); + } + + UpdateCanAutohideProperty(); + base.OnItemsChanged(e); } + void DockablePane_Loaded(object sender, RoutedEventArgs e) { } + void DockablePane_Unloaded(object sender, RoutedEventArgs e) { - UnloadOptionsContextMenu(); + CloseOptionsMenu(); } + /// + /// This guid is saved with the dockable content so that can be restored in the case is + /// referenced by a dockable content + /// + internal Guid ID = Guid.NewGuid(); #region Dependency properties - public bool ShowHeader - { - get { return (bool)GetValue(ShowHeaderProperty); } - set { SetValue(ShowHeaderProperty, value); } - } - - // Using a DependencyProperty as the backing store for ActiveContent. This enables animation, styling, binding, etc... - public static readonly DependencyProperty ShowHeaderProperty = - DependencyProperty.Register("ShowHeader", typeof(bool), typeof(DockablePane), new UIPropertyMetadata(true)); - - public bool ShowTabs { get { return (bool)GetValue(ShowTabsProperty); } @@ -153,18 +173,80 @@ namespace AvalonDock _partHeader.MouseUp += new MouseButtonEventHandler(OnHeaderMouseUp); _partHeader.MouseEnter += new MouseEventHandler(OnHeaderMouseEnter); _partHeader.MouseLeave += new MouseEventHandler(OnHeaderMouseLeave); + + _partHeader.MouseRightButtonDown += (s, e) => + { + OpenOptionsMenu(null); e.Handled = true; + }; + } + + var optionsMenuPopupElement = GetTemplateChild("PART_ShowContextMenuButton") as Border; + + if (optionsMenuPopupElement != null) + { + optionsMenuPopupElement.MouseLeftButtonDown += (s, e) => { OpenOptionsMenu(s as UIElement); e.Handled = true; }; } - _optionsContextMenuPlacementTarget = GetTemplateChild("PART_ShowContextMenuButton") as UIElement; + } + #region CanAutohide + + /// + /// CanAutohide Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey CanAutohidePropertyKey + = DependencyProperty.RegisterReadOnly("CanAutohide", typeof(bool), typeof(DockablePane), + new FrameworkPropertyMetadata((bool)false)); + + public static readonly DependencyProperty CanAutohideProperty + = CanAutohidePropertyKey.DependencyProperty; + + /// + /// Gets the CanAutohide property. This dependency property + /// indicates if contents inside pane can be autohidden. + /// + public bool CanAutohide + { + get { return (bool)GetValue(CanAutohideProperty); } + } + + /// + /// Provides a secure method for setting the CanAutohide property. + /// This dependency property indicates if contents inside pane can be autohidden. + /// + /// The new value for the property. + protected void SetCanAutohide(bool value) + { + SetValue(CanAutohidePropertyKey, value); + } + + internal void UpdateCanAutohideProperty() + { + SetCanAutohide( + Items.Cast().All(c => + { + bool flag = c.State == DockableContentState.Docked || + c.State == DockableContentState.Document || + c.State == DockableContentState.AutoHide; + + flag = flag && ((c.DockableStyle & DockableStyle.AutoHide) > 0); +#if DEBUG + Debug.WriteLine("{0} CanAutohide()= {1}", c.Title, flag); +#endif + return flag; + }) + ); + } - #endregion - - - public override bool IsSurfaceVisible + + + #endregion + + + protected override bool IsSurfaceVisible { get { @@ -173,7 +255,8 @@ namespace AvalonDock if (managedContent is DocumentContent) continue; - if (((DockableContent)managedContent).State == DockableContentState.Docked) + if (((DockableContent)managedContent).State == DockableContentState.Docked || + ((DockableContent)managedContent).State == DockableContentState.None) return true; } @@ -185,45 +268,33 @@ namespace AvalonDock #region OptionsContextMenu ContextMenu cxOptions = null; - UIElement _optionsContextMenuPlacementTarget = null; - - void LoadOptionsContextMenu() - { - Debug.Assert(cxOptions == null); - cxOptions = FindResource(new ComponentResourceKey(typeof(DockingManager), ContextMenuElement.DockablePane)) as ContextMenu; - cxOptions.Opened += new RoutedEventHandler(cxOptions_RefreshOpenState); - cxOptions.Closed += new RoutedEventHandler(cxOptions_RefreshOpenState); - } - - void UnloadOptionsContextMenu() - { - if (cxOptions != null) - { - cxOptions.Opened -= new RoutedEventHandler(cxOptions_RefreshOpenState); - cxOptions.Closed -= new RoutedEventHandler(cxOptions_RefreshOpenState); - cxOptions = null; - } - } - - - protected virtual void OpenOptionsContextMenu() + /// + /// Open the option context menu + /// + public bool OpenOptionsMenu(UIElement menuTarget) { if (cxOptions == null) { - LoadOptionsContextMenu(); + Debug.Assert(cxOptions == null); + cxOptions = TryFindResource(new ComponentResourceKey(typeof(DockingManager), ContextMenuElement.DockablePane)) as ContextMenu; + if (cxOptions != null) + { + cxOptions.Opened += (s, e) => IsOptionsMenuOpen = true; + cxOptions.Closed += (s, e) => IsOptionsMenuOpen = false; + } } if (cxOptions != null) { cxOptions.DataContext = this.SelectedItem as DockableContent; - foreach (MenuItem menuItem in cxOptions.Items) + foreach (MenuItem menuItem in cxOptions.Items.OfType()) menuItem.CommandTarget = this.SelectedItem as DockableContent; - if (_optionsContextMenuPlacementTarget != null) + if (menuTarget != null) { cxOptions.Placement = PlacementMode.Bottom; - cxOptions.PlacementTarget = _optionsContextMenuPlacementTarget; + cxOptions.PlacementTarget = menuTarget; } else { @@ -231,26 +302,42 @@ namespace AvalonDock cxOptions.PlacementTarget = this; } + FocusContent(); cxOptions.IsOpen = true; - } - } + } - void cxOptions_RefreshOpenState(object sender, RoutedEventArgs e) - { - NotifyPropertyChanged("IsOptionsMenuOpened"); - } + return (cxOptions != null && cxOptions.IsOpen); + } - public bool IsOptionsMenuOpened + /// + /// Close the options context menu + /// + public void CloseOptionsMenu() { - get + if (cxOptions != null) { - return cxOptions != null && cxOptions.IsOpen && ( - _optionsContextMenuPlacementTarget != null ? - cxOptions.PlacementTarget == _optionsContextMenuPlacementTarget : - cxOptions.PlacementTarget == this); + cxOptions.IsOpen = false; + cxOptions = null; } } + /// + /// Gets a value indicating if the options context menu is open + /// + public bool IsOptionsMenuOpen + { + get { return (bool)GetValue(IsOptionsMenuOpenProperty); } + protected set { SetValue(IsOptionsMenuOpenPropertyKey, value); } + } + + // Using a DependencyProperty as the backing store for IsOptionsMenuOpen. This enables animation, styling, binding, etc... + static readonly DependencyPropertyKey IsOptionsMenuOpenPropertyKey = + DependencyProperty.RegisterReadOnly("IsOptionsMenuOpen", typeof(bool), typeof(DockablePane), new UIPropertyMetadata(false)); + + public static readonly DependencyProperty IsOptionsMenuOpenProperty = IsOptionsMenuOpenPropertyKey.DependencyProperty; + + + #endregion #region Mouse management @@ -258,11 +345,12 @@ namespace AvalonDock void FocusContent() { ManagedContent selectedContent = SelectedItem as ManagedContent; - if (selectedContent != null && selectedContent.Content is UIElement) + if (selectedContent != null)// && selectedContent.Content is UIElement) { - //UIElement internalContent = selectedContent.Content as UIElement; - //bool res = internalContent.Focus(); - selectedContent.SetAsActive(); + UIElement internalContent = selectedContent.Content as UIElement; + bool res = Focus(); + //Keyboard.Focus(internalContent); + selectedContent.Activate(); } } @@ -270,13 +358,15 @@ namespace AvalonDock bool isMouseDown = false; protected virtual void OnHeaderMouseDown(object sender, MouseButtonEventArgs e) { - if (!e.Handled) + if (!e.Handled && SelectedItem != null) { FocusContent(); if (((DockableContent)SelectedItem).State != DockableContentState.AutoHide) { - ptStartDrag = e.MouseDevice.GetPosition(this); + //ptStartDrag = e.MouseDevice.GetPosition(this); + ptStartDrag = e.GetPosition((IInputElement)System.Windows.Media.VisualTreeHelper.GetParent(this)); + isMouseDown = true; } } @@ -284,21 +374,25 @@ namespace AvalonDock protected virtual void OnHeaderMouseMove(object sender, MouseEventArgs e) { - Point ptMouseMove = e.GetPosition(this); + //Point ptMouseMove = e.GetPosition(this); + Point ptMouseMove = e.GetPosition((IInputElement)System.Windows.Media.VisualTreeHelper.GetParent(this)); + - if (!e.Handled && isMouseDown) + if (!e.Handled && isMouseDown && e.LeftButton == MouseButtonState.Pressed) { if (_partHeader != null && _partHeader.IsMouseOver) { - if (!IsMouseCaptured) + DockingManager manager = GetManager(); + if (!manager.DragPaneServices.IsDragging && + !IsMouseCaptured) { if (Math.Abs(ptMouseMove.X - ptStartDrag.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(ptMouseMove.Y - ptStartDrag.Y) > SystemParameters.MinimumVerticalDragDistance) { isMouseDown = false; ReleaseMouseCapture(); - DockingManager manager = GetManager(); + manager.Drag(this, this.PointToScreenDPI(e.GetPosition(this)), e.GetPosition(this)); e.Handled = true; } @@ -327,82 +421,63 @@ namespace AvalonDock #endregion #region Commands - private static object syncRoot = new object(); - private static RoutedUICommand optionsCommand = null; - public static RoutedUICommand ShowOptionsCommand + protected override void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) { - get + if (e.Command == DockablePaneCommands.Close) { - lock (syncRoot) - { - if (null == optionsCommand) - { - optionsCommand = new RoutedUICommand("S_how options", "Options", typeof(DockablePane)); - } - } - return optionsCommand; + Close(); + e.Handled = true; } - } - - private static RoutedUICommand autoHideCommand = null; - public static RoutedUICommand ToggleAutoHideCommand - { - get + else if (e.Command == DockablePaneCommands.Hide) { - lock (syncRoot) - { - if (null == autoHideCommand) - { - autoHideCommand = new RoutedUICommand("A_utohide", "AutoHide", typeof(DockablePane)); - } - } - return autoHideCommand; + Hide(); + e.Handled = true; } - } - - private static RoutedUICommand closeCommand = null; - public static RoutedUICommand CloseCommand - { - get + else if (e.Command == DockablePaneCommands.ToggleAutoHide) { - lock (syncRoot) - { - if (null == closeCommand) - { - closeCommand = new RoutedUICommand("C_lose", "Close", typeof(DockablePane)); - } - } - return closeCommand; + ToggleAutoHide(); + e.Handled = true; } + //else if (e.Command == ShowOptionsCommand) + //{ + // OpenOptionsContextMenu(); + // e.Handled = true; + //} + } + protected override void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = true; + } - internal virtual void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + /// + /// Retrive a value indicating if the command can be executed based to the dockable content state + /// + /// + /// + protected virtual bool CanExecuteCommand(ICommand command) { - if (e.Command == ToggleAutoHideCommand) + //Test by DockableStyle + if (command == DockablePaneCommands.Close) { - ToggleAutoHide(); - e.Handled = true; + return true; } - else if (e.Command == CloseCommand) + else if (command == DockablePaneCommands.Hide) { - CloseOrHide(); - e.Handled = true; + return true; } - else if (e.Command == ShowOptionsCommand) + else if (command == DockablePaneCommands.ToggleAutoHide) { - OpenOptionsContextMenu(); - e.Handled = true; + return true; } + + return true; } - protected virtual void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) - { - e.CanExecute = true; - } #endregion @@ -412,6 +487,14 @@ namespace AvalonDock get { return IsSurfaceVisible; } } + public bool IsAutoHidden + { + get + { + return Items.Cast().FirstOrDefault(c => c.State == DockableContentState.AutoHide) != null; + } + } + public DockableStyle GetCumulativeDockableStyle() { @@ -431,21 +514,25 @@ namespace AvalonDock return style; } - public override ManagedContent RemoveContent(int index) - { - ManagedContent content = base.RemoveContent(index); - - if (Items.Count == 0) - { - ResizingPanel containerPanel = Parent as ResizingPanel; - if (containerPanel != null) - containerPanel.RemoveChild(this); - } - - return content; - } - - protected virtual void CheckItems(IList newItems) + internal override ManagedContent RemoveContent(int index) + { + ManagedContent content = base.RemoveContent(index); + DockableContent dockableContent = content as DockableContent; + + if (((dockableContent == null) + || (dockableContent != null && dockableContent.SavedStateAndPosition == null) + || (dockableContent != null && dockableContent.SavedStateAndPosition.ContainerPane != this)) + && Items.Count == 0) + { + ResizingPanel containerPanel = Parent as ResizingPanel; + if (containerPanel != null) + containerPanel.RemoveChild(this); + } + + return content; + } + + protected override void CheckItems(IList newItems) { foreach (object newItem in newItems) { @@ -454,48 +541,70 @@ namespace AvalonDock } } - protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + + #region Dockable Pane operations + /// + /// Toggle auto hide state to all content inside the pane + /// + public virtual void ToggleAutoHide() { - if (e.NewItems != null) - CheckItems(e.NewItems); + bool flag = Items.OfType().FirstOrDefault(c => (c.DockableStyle & DockableStyle.AutoHide) == 0) == null; - base.OnItemsChanged(e); + if (flag && GetManager() != null) + GetManager().ToggleAutoHide(this); } + /// + /// Close pane and all contained contents + /// + /// True if all content has been closed, false if at least one content couldn't be closed. + /// + public virtual bool Close() + { + DockableContent[] cntsToClose = Items.OfType().ToArray(); + bool res = true; + foreach (var cnt in cntsToClose) + { + if (!cnt.Close()) + res = false; + } + return res; + } - #region Dockable Pane operations - /// - /// Show/Hide a flyout window containing this pane + + /// + /// Close pane and hide all contained contents /// - internal virtual void ToggleAutoHide() + /// True if all content has been hidden, false if at least one content couldn't be hidden. + /// + public virtual bool Hide() { - bool flag = true; - foreach (DockableContent cnt in this.Items) + DockableContent[] cntsToClose = Items.OfType().ToArray(); + bool res = true; + foreach (var cnt in cntsToClose) { - if ((cnt.DockableStyle & DockableStyle.AutoHide) == 0) - { - flag = false; - break; - } + if (!cnt.Hide()) + res = false; } - if (flag && GetManager() != null) - GetManager().ToggleAutoHide(this); + + return res; } /// /// Closes or hides current content depending on HideOnClose property /// - internal void CloseOrHide() + internal void CloseOrHideCurrentContent() { - CloseOrHide(SelectedItem as DockableContent, false); + (SelectedItem as DockableContent).CloseOrHide(false); } - #endregion + + } } diff --git a/src/Libraries/AvalonDock/AvalonDock/DockablePaneAnchorTab.cs b/src/Libraries/AvalonDock/AvalonDock/DockablePaneAnchorTab.cs new file mode 100644 index 0000000000..8e0b037bd6 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DockablePaneAnchorTab.cs @@ -0,0 +1,248 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Diagnostics; + +namespace AvalonDock +{ + /// + /// Represents a tab displayed in a border of the docking manager + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public class DockablePaneAnchorTab : System.Windows.Controls.Control//, INotifyPropertyChanged + { + static DockablePaneAnchorTab() + { + //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. + //This style is defined in themes\generic.xaml + DefaultStyleKeyProperty.OverrideMetadata(typeof(DockablePaneAnchorTab), new FrameworkPropertyMetadata(typeof(DockablePaneAnchorTab))); + } + + public DockablePaneAnchorTab() + { + + } + + /// + /// Gets or sets the referenced content + /// + public DockableContent ReferencedContent + { + get { return (DockableContent)GetValue(ReferencedContentPropertyKey.DependencyProperty); } + set { SetValue(ReferencedContentPropertyKey, value); } + } + + // Using a DependencyProperty as the backing store for DockableContent. This enables animation, styling, binding, etc... + public static readonly DependencyPropertyKey ReferencedContentPropertyKey = + DependencyProperty.RegisterReadOnly("ReferencedContent", typeof(DockableContent), typeof(DockablePaneAnchorTab), new UIPropertyMetadata(null, new PropertyChangedCallback(OnPaneAttached))); + + /// + /// Handles the referencedContent property changes in order to update the Anchor property + /// + /// + /// + static void OnPaneAttached(DependencyObject depObj, DependencyPropertyChangedEventArgs e) + { + //Update Anchor, Title and Icon property + DockablePaneAnchorTab _this = depObj as DockablePaneAnchorTab; + _this.SetAnchor(((DockablePane)_this.ReferencedContent.ContainerPane).Anchor); + _this.SetIcon(_this.ReferencedContent.Icon); + _this.SetTitle(_this.ReferencedContent.Title); + + } + + ///// + ///// Gets anchor style of the referenced content + ///// + ///// This proprety is exposed to facilitate the control template binding. + //public AnchorStyle Anchor + //{ + // get { return (AnchorStyle)GetValue(AnchorPropertyKey.DependencyProperty); } + // protected set { SetValue(AnchorPropertyKey, value); } + //} + + //// Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc... + //public static readonly DependencyPropertyKey AnchorPropertyKey = + // DependencyProperty.RegisterAttachedReadOnly("Anchor", typeof(AnchorStyle), typeof(DockablePaneAnchorTab), new PropertyMetadata(AnchorStyle.Left)); + + ///// + ///// Gets icon of the referenced content + ///// + ///// This proprety is exposed to facilitate the control template binding. + //public object Icon + //{ + // get { return (object)GetValue(IconPropertyKey.DependencyProperty); } + // protected set { SetValue(IconPropertyKey, value); } + //} + + //// Using a DependencyProperty as the backing store for IsSelected. This enables animation, styling, binding, etc... + //public static readonly DependencyPropertyKey IconPropertyKey = + // DependencyProperty.RegisterAttachedReadOnly("Icon", typeof(object), typeof(DockablePaneAnchorTab), new PropertyMetadata(null)); + + #region Anchor + + /// + /// Anchor Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey AnchorPropertyKey + = DependencyProperty.RegisterReadOnly("Anchor", typeof(AnchorStyle), typeof(DockablePaneAnchorTab), + new FrameworkPropertyMetadata((AnchorStyle)AnchorStyle.None)); + + public static readonly DependencyProperty AnchorProperty + = AnchorPropertyKey.DependencyProperty; + + /// + /// Gets the Anchor property. This dependency property + /// indicates the achor style of referenced content that is in autohidden state. + /// + public AnchorStyle Anchor + { + get { return (AnchorStyle)GetValue(AnchorProperty); } + } + + /// + /// Provides a secure method for setting the Anchor property. + /// This dependency property indicates the achor style of referenced content that is in autohidden state. + /// + /// The new value for the property. + protected void SetAnchor(AnchorStyle value) + { + SetValue(AnchorPropertyKey, value); + } + + #endregion + + #region Icon + + /// + /// Icon Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey IconPropertyKey + = DependencyProperty.RegisterReadOnly("Icon", typeof(object), typeof(DockablePaneAnchorTab), + new FrameworkPropertyMetadata((object)null)); + + public static readonly DependencyProperty IconProperty + = IconPropertyKey.DependencyProperty; + + /// + /// Gets the Icon property. This dependency property + /// indicates icon of the referenced content in autohidden state. + /// + public object Icon + { + get { return (object)GetValue(IconProperty); } + } + + /// + /// Provides a secure method for setting the Icon property. + /// This dependency property indicates icon of the referenced content in autohidden state. + /// + /// The new value for the property. + protected void SetIcon(object value) + { + SetValue(IconPropertyKey, value); + } + + #endregion + + #region Title + + /// + /// Title Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey TitlePropertyKey + = DependencyProperty.RegisterReadOnly("Title", typeof(object), typeof(DockablePaneAnchorTab), + new FrameworkPropertyMetadata((string)null)); + + public static readonly DependencyProperty TitleProperty + = TitlePropertyKey.DependencyProperty; + + /// + /// Gets the Title property. This dependency property + /// indicates title of the content that is hosted in autohidden pane. + /// + public object Title + { + get { return (object)GetValue(TitleProperty); } + } + + /// + /// Provides a secure method for setting the Title property. + /// This dependency property indicates title of the content that is hosted in autohidden pane. + /// + /// The new value for the property. + protected void SetTitle(object value) + { + SetValue(TitlePropertyKey, value); + } + + #endregion + + /// + /// Handles the MouseMove event + /// + /// + /// Notify the docking manager that the referenced content should appears + protected override void OnMouseMove(MouseEventArgs e) + { + if (ReferencedContent != null) + ReferencedContent.Manager.ShowFlyoutWindow(ReferencedContent, this); + + base.OnMouseMove(e); + } + + /// + /// Handles the MouseDown event + /// + /// + /// Notify the docking manager that the referenced content should appears and should be activated + protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) + { + if (ReferencedContent != null) + { + ReferencedContent.Manager.ShowFlyoutWindow(ReferencedContent, this); + ReferencedContent.Activate(); + } + + base.OnMouseLeftButtonDown(e); + } + + } + +} diff --git a/src/Libraries/AvalonDock/DockablePaneAnchorTabGroup.cs b/src/Libraries/AvalonDock/AvalonDock/DockablePaneAnchorTabGroup.cs similarity index 98% rename from src/Libraries/AvalonDock/DockablePaneAnchorTabGroup.cs rename to src/Libraries/AvalonDock/AvalonDock/DockablePaneAnchorTabGroup.cs index 31bec6929b..6e73ba0b98 100644 --- a/src/Libraries/AvalonDock/DockablePaneAnchorTabGroup.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockablePaneAnchorTabGroup.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, diff --git a/src/Libraries/AvalonDock/AvalonDock/DockablePaneCommands.cs b/src/Libraries/AvalonDock/AvalonDock/DockablePaneCommands.cs new file mode 100644 index 0000000000..0da812b30a --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DockablePaneCommands.cs @@ -0,0 +1,102 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + /// + /// Defines commands that can be applied to a dockable pane + /// + public sealed class DockablePaneCommands + { + private static object syncRoot = new object(); + + private static RoutedUICommand closeCommand = null; + + /// + /// This command closes the and closes all the contained s inside it + /// + public static RoutedUICommand Close + { + get + { + lock (syncRoot) + { + if (null == closeCommand) + { + closeCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockablePaneCommands_Close, "Close", typeof(DockablePaneCommands)); + } + } + return closeCommand; + } + } + + private static RoutedUICommand hideCommand = null; + + /// + /// This command closes the and hides all the contained s inside it + /// + public static RoutedUICommand Hide + { + get + { + lock (syncRoot) + { + if (null == hideCommand) + { + hideCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockablePaneCommands_Hide, "Hide", typeof(DockablePaneCommands)); + } + } + return hideCommand; + } + } + + private static RoutedUICommand autoHideCommand = null; + + /// + /// This commands auto-hides the pane with all contained s inside it + /// + public static RoutedUICommand ToggleAutoHide + { + get + { + lock (syncRoot) + { + if (null == autoHideCommand) + { + autoHideCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DockablePaneCommands_ToggleAutoHide, "AutoHide", typeof(DockablePaneCommands)); + } + } + return autoHideCommand; + } + } + + } +} diff --git a/src/Libraries/AvalonDock/DockableTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/DockableTabPanel.cs similarity index 70% rename from src/Libraries/AvalonDock/DockableTabPanel.cs rename to src/Libraries/AvalonDock/AvalonDock/DockableTabPanel.cs index 5c684a74d3..5572d452ec 100644 --- a/src/Libraries/AvalonDock/DockableTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockableTabPanel.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -43,52 +43,26 @@ namespace AvalonDock protected override Size MeasureOverride(Size availableSize) { double totWidth = 0; - //double maxHeight = 0; - if (Children.Count == 0) + if (base.VisualChildrenCount == 0) return base.MeasureOverride(availableSize); - List childsOrderedByWidth = new List(); + var childsOrderedByWidth = new List(); foreach (FrameworkElement child in Children) { - child.Width = double.NaN; - child.Height = double.NaN; - child.Measure(new Size(double.PositiveInfinity, availableSize.Height)); - totWidth += child.DesiredSize.Width; + totWidth += child.DesiredSize.Width - child.Margin.Left - child.Margin.Right; childsOrderedByWidth.Add(child); } if (totWidth > availableSize.Width) { - childsOrderedByWidth.Sort(delegate(UIElement elem1, UIElement elem2) { return elem2.DesiredSize.Width.CompareTo(elem1.DesiredSize.Width); }); - - - int i = childsOrderedByWidth.Count - 1; - double sumWidth = 0; - - while (childsOrderedByWidth[i].DesiredSize.Width * (i + 1) + sumWidth < availableSize.Width) + foreach (FrameworkElement child in Children) { - sumWidth += childsOrderedByWidth[i].DesiredSize.Width; - - i--; - - if (i < 0) - break; - + child.Measure(new Size(availableSize.Width / Children.Count, availableSize.Height)); } - - double shWidth = (availableSize.Width - sumWidth) / (i + 1); - - - foreach (UIElement child in Children) - { - if (shWidth < child.DesiredSize.Width) - child.Measure(new Size(shWidth, availableSize.Height)); - } - } return base.MeasureOverride(availableSize); @@ -103,7 +77,7 @@ namespace AvalonDock double childFinalWidth = child.DesiredSize.Width; child.Arrange(new Rect(offsetX, 0, childFinalWidth, finalSize.Height)); - offsetX += childFinalWidth; + offsetX += child.DesiredSize.Width; } return base.ArrangeOverride(finalSize); diff --git a/src/Libraries/AvalonDock/DockingManager.cs b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs similarity index 57% rename from src/Libraries/AvalonDock/DockingManager.cs rename to src/Libraries/AvalonDock/AvalonDock/DockingManager.cs index 30e4a7807e..85ce9b84ab 100644 --- a/src/Libraries/AvalonDock/DockingManager.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DockingManager.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -45,27 +45,31 @@ using System.Collections; using System.Collections.Specialized; using System.Collections.ObjectModel; + namespace AvalonDock { /// /// Represents a control which manages a dockable layout for its children /// - public class DockingManager : System.Windows.Controls.ContentControl, IDropSurface, INotifyPropertyChanged, IDisposable + public class DockingManager : ContentControl, IDropSurface, INotifyPropertyChanged, IDisposable { static DockingManager() { - //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. - //This style is defined in themes\generic.xaml DefaultStyleKeyProperty.OverrideMetadata(typeof(DockingManager), new FrameworkPropertyMetadata(typeof(DockingManager))); } public DockingManager() { - DragPaneServices.Register(this); - this.Unloaded += new RoutedEventHandler(DockingManager_Unloaded); + Debug.WriteLine("DockingManager ctr"); + + Documents = new ManagedContentCollection(this); + DockableContents = new ManagedContentCollection(this); + //HiddenContents = new ManagedContentCollection(this); + this.Loaded += new RoutedEventHandler(DockingManager_Loaded); + this.Unloaded += new RoutedEventHandler(DockingManager_Unloaded); } @@ -79,56 +83,61 @@ namespace AvalonDock void DockingManager_Loaded(object sender, RoutedEventArgs e) { - foreach (FloatingWindow floatingWindow in _floatingWindows) + Debug.WriteLine("DockingManager Loaded"); + + if (!DesignerProperties.GetIsInDesignMode(this)) { - floatingWindow.Owner = Window.GetWindow(this); + foreach (FloatingWindow floatingWindow in _floatingWindows) + { + floatingWindow.Owner = Window.GetWindow(this); + if (floatingWindow.IsVisible) + floatingWindow.Hide(); + + floatingWindow.Show(); + } - floatingWindow.Show(); + DragPaneServices.Register(this); } - DragPaneServices.Register(this); _isControlLoaded = true; } void DockingManager_Unloaded(object sender, RoutedEventArgs e) { - //cleanup pending resources - HideAutoHideWindow(); - + Debug.WriteLine("DockingManager Unloaded"); - if (_wndInteropWrapper != null) + if (!DesignerProperties.GetIsInDesignMode(this)) { - _wndInteropWrapper.OnWindowPosChanging -= new EventHandler(_wndInteropWrapper_OnWindowPosChanging); - _wndInteropWrapper.Dispose(); - _wndInteropWrapper = null; - } + //cleanup pending resources + HideFlyoutWindow(); - if (_overlayWindow != null) - { - _overlayWindow.Close(); - _overlayWindow = null; - } + if (_overlayWindow != null) + { + _overlayWindow.Close(); + _overlayWindow = null; + } - foreach (FloatingWindow floatingWindow in _floatingWindows) - floatingWindow.Hide(); + foreach (FloatingWindow floatingWindow in _floatingWindows) + floatingWindow.Hide(); - //navigator windows are now automatically disposed when - //no longer used. In this way we avoid WPF bug: - //http://social.msdn.microsoft.com/forums/en/wpf/thread/f3fc5b7e-e035-4821-908c-b6c07e5c7042/ - //if (navigatorWindow != null) - //{ - // navigatorWindow.Close(); - // navigatorWindow = null; - //} + //navigator windows are now automatically disposed when + //no longer used. In this way we avoid WPF bug: + //http://social.msdn.microsoft.com/forums/en/wpf/thread/f3fc5b7e-e035-4821-908c-b6c07e5c7042/ + //if (navigatorWindow != null) + //{ + // navigatorWindow.Close(); + // navigatorWindow = null; + //} - //if (documentNavigatorWindow != null) - //{ - // documentNavigatorWindow.Close(); - // documentNavigatorWindow = null; - //} + //if (documentNavigatorWindow != null) + //{ + // documentNavigatorWindow.Close(); + // documentNavigatorWindow = null; + //} - DragPaneServices.Unregister(this); + DragPaneServices.Unregister(this); + } _isControlLoaded = false; } @@ -229,98 +238,181 @@ namespace AvalonDock #region Access to contents and pane - ManagedContent _activeDocument = null; + + #region ActiveDocument + + + /// + /// ActiveDocument Dependency Property + /// + public static readonly DependencyProperty ActiveDocumentProperty = + DependencyProperty.Register("ActiveDocument", typeof(ManagedContent), typeof(DockingManager), + new FrameworkPropertyMetadata(null, + new PropertyChangedCallback(OnActiveDocumentChanged), + new CoerceValueCallback(CoerceActiveDocumentValue))); /// - /// Get or set the active document + /// Gets or sets the ActiveDocument property. This dependency property + /// indicates currently active document. /// /// The active document not neessary receive keyboard focus. To set keyboard focus on a content see public ManagedContent ActiveDocument { - get + get { return (ManagedContent)GetValue(ActiveDocumentProperty); } + set { SetValue(ActiveDocumentProperty, value); } + } + + /// + /// Handles changes to the ActiveDocument property. + /// + private static void OnActiveDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((DockingManager)d).OnActiveDocumentChanged(e); + } + + /// + /// Provides derived classes an opportunity to handle changes to the ActiveDocument property. + /// + protected virtual void OnActiveDocumentChanged(DependencyPropertyChangedEventArgs e) + { + var cntActivated = e.NewValue as ManagedContent; + var cntDeactivated = e.OldValue as ManagedContent; + + if (cntDeactivated != null) + cntDeactivated.SetIsActiveDocument(false); + + if (cntActivated != null) + cntActivated.SetIsActiveDocument(true); + + if (ActiveContent == null) + ActiveContent = cntActivated; + + NotifyPropertyChanged("ActiveDocument"); + + if (ActiveDocumentChanged != null) + ActiveDocumentChanged(this, EventArgs.Empty); + + if (ActiveDocument == null) { - return _activeDocument; + var docToActivate = Documents.OrderBy(d => d.LastActivation).FirstOrDefault(); + if (docToActivate != null) + docToActivate.Activate(); } - set + } + + /// + /// Coerces the ActiveDocument value. + /// + private static object CoerceActiveDocumentValue(DependencyObject d, object value) + { + var contentToCoerce = value as ManagedContent; + if (contentToCoerce != null && + (contentToCoerce.ContainerPane == null || + contentToCoerce.ContainerPane.GetManager() != d)) { - //Debug.WriteLine(string.Format("SetActiveDocument to '{0}'", value != null ? value.Name : "null")); + //value is not contained in a document pane/ documentfloatingwindow so cant be the active document! + throw new InvalidOperationException("Unable to set active document"); + } - if (_activeDocument != value/* && - value.ContainerPane is DocumentPane*/) - { - if (value != null && - (value.FindVisualAncestor(false) == null && - !(value is DocumentContent)) - ) - { - //value is not contained in a document pane/ documentfloatingwindow so cant be the active document! - return; - } + return value; + } - List listOfAllDocuments = FindContents(); - listOfAllDocuments.ForEach((ManagedContent cnt) => - { - cnt.IsActiveDocument = cnt == value; - }); + /// + /// Raised whenever the property changes + /// + public event EventHandler ActiveDocumentChanged; - _activeDocument = value; - NotifyPropertyChanged("ActiveDocument"); + #endregion - if (ActiveContent == null) - ActiveContent = value; - } - } - } - ManagedContent _activeContent = null; + //ManagedContent _activeContent = null; + + ///// + ///// Get or set the active content + ///// + ///// An activated content is automatically selected in its container pane and receive logical as well keyboard focus. + //public ManagedContent ActiveContent + //{ + // get + // { + // return _activeContent; + // } + // internal set + // { + + // } + //} + + #region ActiveContent + + /// + /// ActiveContent Dependency Property + /// + public static readonly DependencyProperty ActiveContentProperty = + DependencyProperty.Register("ActiveContent", typeof(ManagedContent), typeof(DockingManager), + new FrameworkPropertyMetadata(null, + new PropertyChangedCallback(OnActiveContentChanged), + new CoerceValueCallback(CoerceActiveContentValue))); /// - /// Get or set the active content + /// Gets or sets the ActiveContent property. This dependency property + /// indicates the active content. /// - /// An activated content is automatically selected in its container pane and receive logical as well keyboard focus. public ManagedContent ActiveContent { - get - { - return _activeContent; - } - internal set - { - //Debug.WriteLine(string.Format("SetActiveContent to '{0}'", value != null ? value.Name : "null")); - ActiveDocument = value; + get { return (ManagedContent)GetValue(ActiveContentProperty); } + set { SetValue(ActiveContentProperty, value); } + } - if (_activeContent != value) - { - List listOfAllContents = FindContents(); - listOfAllContents.ForEach((ManagedContent cnt) => - { - cnt.IsActiveContent = (value == cnt); - }); + /// + /// Handles changes to the ActiveContent property. + /// + private static void OnActiveContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((DockingManager)d).OnActiveContentChanged(e); + } - _floatingWindows.ForEach((DockableFloatingWindow fw) => - { - foreach (DockableContent cnt in fw.HostedPane.Items) - { - cnt.IsActiveContent = (value == cnt); - } - }); - if (_flyoutWindow != null) - { - foreach (DockableContent cnt in _flyoutWindow.ReferencedPane.Items) - { - cnt.IsActiveContent = (value == cnt); - } - } + /// + /// Provides derived classes an opportunity to handle changes to the ActiveContent property. + /// + protected virtual void OnActiveContentChanged(DependencyPropertyChangedEventArgs e) + { + var cntActivated = e.NewValue as ManagedContent; + var cntDeactivated = e.OldValue as ManagedContent; + if (cntDeactivated != null) + cntDeactivated.SetIsActiveContent(false); - _activeContent = value; - NotifyPropertyChanged("ActiveContent"); - } + if (cntActivated != null) + cntActivated.SetIsActiveContent(true); - } + if (cntActivated != null && + cntActivated.ContainerPane is DocumentPane) + ActiveDocument = cntActivated; + + //for backward compatibility + NotifyPropertyChanged("ActiveContent"); + + if (ActiveContentChanged != null) + ActiveContentChanged(this, EventArgs.Empty); + } + + /// + /// Coerces the ActiveContent value. + /// + private static object CoerceActiveContentValue(DependencyObject d, object value) + { + return value; } + /// + /// Raised whenever the changes + /// + public event EventHandler ActiveContentChanged; + + #endregion + /// /// Gets the active dockable content /// @@ -338,38 +430,83 @@ namespace AvalonDock /// /// Gets an array of all dockable contents currenty managed /// - public DockableContent[] DockableContents - { - get - { - List contents = FindContents(); + //public DockableContent[] DockableContents + //{ + // get + // { + // List contents = FindContents(); - //FindContents already returns contents from FloatingWindows (sg #68987) - //foreach (FloatingWindow flWindow in _floatingWindows) - //{ - // foreach (DockableContent content in flWindow.HostedPane.Items) - // contents.Add(content); - //} + // foreach (DockableContent content in HiddenContents) + // contents.Add(content); - foreach (DockableContent content in _hiddenContents) - contents.Add(content); + // return contents.ToArray(); + // } + //} + #region DockableContents - return contents.ToArray(); - } + /// + /// DockableContents Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey DockableContentsPropertyKey + = DependencyProperty.RegisterReadOnly("DockableContents", typeof(ManagedContentCollection), typeof(DockingManager), + new FrameworkPropertyMetadata(null)); + + public static readonly DependencyProperty DockableContentsProperty + = DockableContentsPropertyKey.DependencyProperty; + + /// + /// Gets the DockableContents property. This dependency property + /// retrives the collection of that are bound to + /// + public ManagedContentCollection DockableContents + { + get { return (ManagedContentCollection)GetValue(DockableContentsProperty); } + protected set { SetValue(DockableContentsPropertyKey, value); } } + #endregion + + + #region Documents /// - /// Gets an array of all document contents + /// DockableContents Read-Only Dependency Property /// - public DocumentContent[] Documents + private static readonly DependencyPropertyKey DocumentsPropertyKey + = DependencyProperty.RegisterReadOnly("Documents", typeof(ManagedContentCollection), typeof(DockingManager), + new FrameworkPropertyMetadata(null)); + + public static readonly DependencyProperty DocumentsProperty + = DocumentsPropertyKey.DependencyProperty; + + /// + /// Gets the DockableContents property. This dependency property + /// retrives the collection of that are bound to + /// + public ManagedContentCollection Documents { - get - { - return FindContents().ToArray(); - } + get { return (ManagedContentCollection)GetValue(DocumentsProperty); } + protected set { SetValue(DocumentsPropertyKey, value); } } + #endregion + + ///// + ///// Gets an array of all document contents + ///// + //public DocumentContent[] Documents + //{ + // get + // { + // return FindContents().ToArray(); + // } + //} + + #region Documents Source + + /// + /// Get or set the source collection for documents + /// [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Bindable(true)] public IEnumerable DocumentsSource { @@ -381,7 +518,6 @@ namespace AvalonDock public static readonly DependencyProperty DocumentsSourceProperty = DependencyProperty.Register("DocumentsSource", typeof(IEnumerable), typeof(DockingManager), new UIPropertyMetadata(null, new PropertyChangedCallback((s, e) => ((DockingManager)s).OnDocumentsSourceChanged(e.OldValue as IEnumerable, e.NewValue as IEnumerable)))); - void OnDocumentsSourceChanged(IEnumerable oldSource, IEnumerable newSource) { if (oldSource != null) @@ -400,42 +536,44 @@ namespace AvalonDock } void DocumentsSourceCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) - { - if (e.Action == NotifyCollectionChangedAction.Reset) - { - DocumentContent[] docs = this.Documents; - ObservableCollection documentsToClose = new ObservableCollection(); - - foreach (DocumentContent doc in docs) - { - if (doc.Parent is DocumentPane) - { - if ((doc.Parent as DocumentPane).IsMainDocumentPane == false) - { - documentsToClose.Add(doc); - } - } - } + { + if (e.Action == NotifyCollectionChangedAction.Reset) + { + //close first documents that do not belong to the MainDocumentPane + DocumentContent[] docs = this.Documents.ToArray(); + List documentsToCloseFirst = new List(); - foreach (DocumentContent doc in documentsToClose) - { - doc.InternalClose(); - } + foreach (DocumentContent doc in docs) + { + if (doc.Parent is DocumentPane) + { + if ((doc.Parent as DocumentPane).IsMainDocumentPane == false) + { + documentsToCloseFirst.Add(doc); + } + } + } - foreach (DocumentContent doc in docs) - doc.InternalClose(); - } + foreach (DocumentContent doc in documentsToCloseFirst) + { + doc.InternalClose(); + } - if (MainDocumentPane == null) - return; + foreach (DocumentContent doc in docs) + doc.InternalClose(); + } - if (e.Action == NotifyCollectionChangedAction.Remove || - e.Action == NotifyCollectionChangedAction.Replace) + if (e.OldItems != null && + (e.Action == NotifyCollectionChangedAction.Remove || + e.Action == NotifyCollectionChangedAction.Replace)) { foreach (object newDoc in e.OldItems) { if (newDoc is DocumentContent) - (newDoc as DocumentContent).InternalClose(); + { + DocumentContent documentToAdd = newDoc as DocumentContent; + documentToAdd.InternalClose(); + } else if (newDoc is FrameworkElement) { DocumentContent docContainer = ((FrameworkElement)newDoc).Parent as DocumentContent; @@ -445,26 +583,58 @@ namespace AvalonDock } } - if (e.Action == NotifyCollectionChangedAction.Add || - e.Action == NotifyCollectionChangedAction.Replace) + if (e.NewItems != null && + (e.Action == NotifyCollectionChangedAction.Add || + e.Action == NotifyCollectionChangedAction.Replace)) { + if (MainDocumentPane == null) + throw new InvalidOperationException("DockingManager must have at least a DocumentPane to host documents"); + + int iInsertIndex = e.NewStartingIndex; foreach (object newDoc in e.NewItems) { if (newDoc is DocumentContent) - MainDocumentPane.Items.Add(newDoc); - else if (newDoc is FrameworkElement) //limit objects to be at least framework elements { - DocumentContent docContainer = new DocumentContent(); - docContainer.Content = newDoc; + DocumentContent documentToAdd = newDoc as DocumentContent; + if (documentToAdd.Parent is DocumentPane) + { + ((DocumentPane)documentToAdd.Parent).Items.Clear(); + } + + MainDocumentPane.Items.Insert(iInsertIndex, documentToAdd); + } + else if (newDoc is UIElement) //limit objects to be at least framework elements + { + DocumentContent documentToAdd = new DocumentContent() + { + Content = newDoc + }; - MainDocumentPane.Items.Add(docContainer); + MainDocumentPane.Items.Insert(iInsertIndex, documentToAdd); } + else + throw new InvalidOperationException(string.Format("Unable to add type {0} as DocumentContent", newDoc)); + + iInsertIndex++; } } } + internal void HandleDocumentClose(DocumentContent contentClosed) + { + IList listToUpdate = DocumentsSource as IList; + if (listToUpdate != null) + listToUpdate.Remove(contentClosed); + } - + internal void HandleDocumentOpen(DocumentContent contentClosed) + { + IList listToUpdate = DocumentsSource as IList; + if (listToUpdate != null) + listToUpdate.Add(contentClosed); + } + #endregion + /// /// Returns the main document pane /// @@ -476,16 +646,7 @@ namespace AvalonDock { if (child is DocumentPane) return child as DocumentPane; - //if (child is DockablePane) - //{ - // DocumentPane doc = new DocumentPane(); - // DockablePane dockablePane = child as DockablePane; - // while (dockablePane.Items.Count > 0) - // { - // doc.Items.Add((dockablePane.Items[0] as DockableContent).DetachFromContainerPane()); - // } - // return doc; - //} + if (child is ResizingPanel) { DocumentPane foundDocPane = GetMainDocumentPane(child as ResizingPanel); @@ -553,7 +714,7 @@ namespace AvalonDock public DocumentPane MainDocumentPane { get { return _mainDocumentPane; } - internal set + set { if (_mainDocumentPane == null) { @@ -564,7 +725,9 @@ namespace AvalonDock foreach (object newDoc in DocumentsSource) { if (newDoc is DocumentContent) + { MainDocumentPane.Items.Add(newDoc); + } else if (newDoc is FrameworkElement) //limit objects to be at least framework elements { DocumentContent docContainer = new DocumentContent(); @@ -583,110 +746,268 @@ namespace AvalonDock } } - internal List FindContents() where T : ManagedContent + protected override void OnContentChanged(object oldContent, object newContent) { - List resList = new List(); - + base.OnContentChanged(oldContent, newContent); + + UpdateLayout(); + RefreshContents(); + } - if (Content is Pane) - { - foreach (ManagedContent c in ((Pane)Content).Items) - { - if (c is T) - { - resList.Add((T)c); - } - } - } - else if (Content is ResizingPanel) + internal void RefreshContents() + { + var contentsFoundUnderMe = new LogicalTreeAdapter(this).Descendants().Where(d => d.Item is ManagedContent).Select(d => d.Item).Cast(); + var contentsFoundInFloatingMode = _floatingWindows.SelectMany(d => d.HostedPane.Items.Cast()); + DockableContent contentFoundInFlyoutMode = null; + + if (_flyoutWindow != null && + _flyoutWindow.ReferencedPane != null && + _flyoutWindow.ReferencedPane.Items.Count > 0) { - FindContents(resList, Content as ResizingPanel); + contentFoundInFlyoutMode = _flyoutWindow.ReferencedPane.Items[0] as DockableContent; } - foreach (FloatingWindow flWindow in _floatingWindows) + var contentsFound = new List(); + contentsFound.AddRange(contentsFoundUnderMe); + contentsFound.AddRange(contentsFoundInFloatingMode); + if (contentFoundInFlyoutMode != null) + contentsFound.Add(contentFoundInFlyoutMode); + + var dockableContensToRemove = DockableContents.Except(contentsFound.OfType()); + var dockableContensToAdd = contentsFound.OfType().Except(DockableContents); + + dockableContensToAdd.ToArray().ForEach(d => { - foreach (ManagedContent c in flWindow.HostedPane.Items) - { - if (c is T) - resList.Add(c as T); - } - } + if (d.State != DockableContentState.Hidden) + DockableContents.Add(d); + }); + dockableContensToRemove.ToArray().ForEach(d => + { + if (d.State != DockableContentState.Hidden) + DockableContents.Remove(d); + }); + + var documentsToRemove = Documents.Except(contentsFound.OfType()); + var documentsToAdd = contentsFound.OfType().Except(Documents); - if (_flyoutWindow != null && _flyoutWindow.ReferencedPane != null) + documentsToAdd.ToArray().ForEach(d => Documents.Add(d)); + documentsToRemove.ToArray().ForEach(d => Documents.Remove(d)); + + //refresh MainDocumentPane + if (MainDocumentPane == null || + MainDocumentPane.GetManager() != this) { - foreach (ManagedContent c in _flyoutWindow.ReferencedPane.Items) - { - if (c is T) - resList.Add(c as T); - } + ILinqToTree itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(d => d.Item is DocumentPane); + + MainDocumentPane = itemFound != null ? itemFound.Item as DocumentPane : null; } - - return resList; + //_floatingWindows.ForEach(fl => fl.CheckContents()); + CheckValidPanesFromTabGroups(); } - - void FindContents(List listOfFoundContents, ResizingPanel parentPanel) where T : ManagedContent + internal void ClearEmptyPanes() { - foreach (UIElement child in parentPanel.Children) + if (RestoringLayout) + return; + + while (true) { - if (child is Pane) + bool foundEmptyPaneToRemove = false; + var emptyDockablePanes = new LogicalTreeAdapter(this).Descendants().Where(i => (i.Item is DockablePane) && (i.Item as DockablePane).Items.Count == 0).Select(i => i.Item).Cast().ToArray(); + + emptyDockablePanes.ForEach(dp => { - foreach (ManagedContent c in ((Pane)child).Items) + if (!DockableContents.Any(dc => + { + if (dc.SavedStateAndPosition != null && + (dc.SavedStateAndPosition.ContainerPane == dp || dc.SavedStateAndPosition.ContainerPaneID == dp.ID)) + return true; + + if (dc.State == DockableContentState.AutoHide) + { + var flyoutDocPane = dc.ContainerPane as FlyoutDockablePane; + if (flyoutDocPane != null && flyoutDocPane.ReferencedPane == dp) + return true; + } + + return false; + })) { - if (c is T) + var containerPanel = dp.Parent as ResizingPanel; + if (containerPanel != null) { - listOfFoundContents.Add((T)c); + containerPanel.RemoveChild(dp); + foundEmptyPaneToRemove = true; } } + }); + + if (!foundEmptyPaneToRemove) + break; + } + + } + + + internal void ClearEmptyPanels(ResizingPanel panelToClear) + { + if (panelToClear == null) + return; + + foreach (var childPanel in panelToClear.Children.OfType().ToArray()) + { + if (childPanel.Children.Count == 0) + { + panelToClear.RemoveChild(childPanel); } - else if (child is ResizingPanel) + else { - FindContents(listOfFoundContents, child as ResizingPanel); + ClearEmptyPanels(childPanel); } } } + /// + /// This method ensure that content of this is not empty + /// + void EnsureContentNotEmpty() + { + if (RestoringLayout) + return; + + if (Content == null) + { + Content = new DocumentPane(); + RefreshContents(); + } + } + + //internal List FindContents() where T : ManagedContent + //{ + // List resList = new List(); + + // if (Content is Pane) + // { + // foreach (ManagedContent c in ((Pane)Content).Items) + // { + // if (c is T) + // { + // resList.Add((T)c); + // } + // } + // } + // else if (Content is ResizingPanel) + // { + // FindContents(resList, Content as ResizingPanel); + // } + + // foreach (FloatingWindow flWindow in _floatingWindows) + // { + // foreach (ManagedContent c in flWindow.HostedPane.Items) + // { + // if (c is T) + // resList.Add(c as T); + // } + // } + + // if (_flyoutWindow != null && _flyoutWindow.ReferencedPane != null) + // { + // foreach (ManagedContent c in _flyoutWindow.ReferencedPane.Items) + // { + // if (c is T) + // resList.Add(c as T); + // } + // } + + + // return resList; + //} + + //void FindContents(List listOfFoundContents, ResizingPanel parentPanel) where T : ManagedContent + //{ + // foreach (UIElement child in parentPanel.Children) + // { + // if (child is Pane) + // { + // foreach (ManagedContent c in ((Pane)child).Items) + // { + // if (c is T) + // { + // listOfFoundContents.Add((T)c); + // } + // } + // } + // else if (child is ResizingPanel) + // { + // FindContents(listOfFoundContents, child as ResizingPanel); + // } + // } + //} + #endregion #region Floating windows management - List _floatingWindows = new List(); + List _floatingWindows = new List(); - public DockableFloatingWindow[] FloatingWindows + /// + /// Get all floating windows created by the while user dragged contents + /// + public FloatingWindow[] FloatingWindows { get { if (_floatingWindows == null || _floatingWindows.Count == 0) - return new DockableFloatingWindow[0]; + return new DockableFloatingWindow[] { }; return _floatingWindows.ToArray(); } } - internal void RegisterFloatingWindow(DockableFloatingWindow floatingWindow) + internal void RegisterFloatingWindow(FloatingWindow floatingWindow) { if (_floatingWindows != null) { floatingWindow.FlowDirection = this.FlowDirection; - _floatingWindows.Add(floatingWindow); + if (!_floatingWindows.Contains(floatingWindow)) + _floatingWindows.Add(floatingWindow); } } - internal void UnregisterFloatingWindow(DockableFloatingWindow floatingWindow) + internal void UnregisterFloatingWindow(FloatingWindow floatingWindow) { if (_floatingWindows != null) _floatingWindows.Remove(floatingWindow); } - - - protected override void OnInitialized(EventArgs e) { base.OnInitialized(e); this.CommandBindings.Clear(); + + //Keyboard.AddKeyDownHandler(this, (s, ke) => + // { + // if (ke.Key == Key.Tab && Keyboard.IsKeyDown(Key.LeftCtrl)) + // { + // ShowNavigatorWindow(); + // ke.Handled = true; + // } + // }); + + //Keyboard.AddKeyDownHandler(this, (s, ke) => + //{ + // if (ke.Key == Key.Tab) + // { + // if (navigatorWindow != null && navigatorWindow.IsVisible) + // { + // HideNavigatorWindow(); + // ke.Handled = true; + // } + // } + //}); + //this.CommandBindings.Add(new CommandBinding(ShowNavigatorWindowCommand, OnExecuteCommand, OnCanExecuteCommand)); //this.CommandBindings.Add(new CommandBinding(ShowDocumentNavigatorWindowCommand, OnExecuteCommand, OnCanExecuteCommand)); } @@ -695,7 +1016,7 @@ namespace AvalonDock { if (e.Property == FlowDirectionProperty) { - _floatingWindows.ForEach((DockableFloatingWindow fl) => + _floatingWindows.ForEach(fl => { fl.FlowDirection = FlowDirection; }); @@ -710,32 +1031,32 @@ namespace AvalonDock } #endregion - #region Commands + //#region Commands - private static object syncRoot = new object(); + //private static object syncRoot = new object(); - private static RoutedUICommand showNavigatorCommand = null; + //private static RoutedUICommand showNavigatorCommand = null; - /// - /// Get the command to show navigator window - /// - public static RoutedUICommand ShowNavigatorWindowCommand - { - get - { - lock (syncRoot) - { - if (null == showNavigatorCommand) - { - showNavigatorCommand = new RoutedUICommand("S_how navigator window", "Navigator", typeof(DockingManager)); - showNavigatorCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Control)); - } - - } - return showNavigatorCommand; - } - } + ///// + ///// Get the command to show navigator window + ///// + //public static RoutedUICommand ShowNavigatorWindowCommand + //{ + // get + // { + // lock (syncRoot) + // { + // if (null == showNavigatorCommand) + // { + // showNavigatorCommand = new RoutedUICommand("S_how navigator window", "Navigator", typeof(DockingManager)); + // showNavigatorCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Control)); + // } + + // } + // return showNavigatorCommand; + // } + //} NavigatorWindow navigatorWindow = null; @@ -754,6 +1075,7 @@ namespace AvalonDock navigatorWindow.Top = locDockingManager.Y; navigatorWindow.Width = this.ActualWidth; navigatorWindow.Height = this.ActualHeight; + navigatorWindow.ShowActivated = false; navigatorWindow.Show(); navigatorWindow.Focus(); } @@ -767,89 +1089,123 @@ namespace AvalonDock } } - - void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + + protected override void OnKeyDown(KeyEventArgs e) { - if (e.Command == ShowNavigatorWindowCommand && ((Keyboard.Modifiers & ModifierKeys.Control)>0) ) - { - ShowNavigatorWindow(); - e.Handled = true; - } - else if (e.Command == ShowDocumentNavigatorWindowCommand && ((Keyboard.Modifiers & ModifierKeys.Shift) > 0)) + bool isCtrlDown = Keyboard.Modifiers == ModifierKeys.Control; + bool _navigatorWindowIsVisible = navigatorWindow != null ? navigatorWindow.IsVisible : false; + Debug.WriteLine(string.Format("OnKeyDn {0} CtrlDn={1}", e.Key, isCtrlDown)); + + if (e.Key == Key.Tab && isCtrlDown) { - ShowDocumentNavigatorWindow(); + if (!_navigatorWindowIsVisible) + { + ShowNavigatorWindow(); + } + + navigatorWindow.MoveNextSelectedContent(); e.Handled = true; } - - } - - void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) - { - e.CanExecute = true; - } - - - private static RoutedUICommand showDocumentNavigatorCommand = null; + else + HideNavigatorWindow(); - /// - /// Get the command to show document navigator window - /// - public static RoutedUICommand ShowDocumentNavigatorWindowCommand - { - get - { - lock (syncRoot) - { - if (null == showDocumentNavigatorCommand) - { - showDocumentNavigatorCommand = new RoutedUICommand("S_how document navigator window", "DocumentNavigator", typeof(DockingManager)); - showDocumentNavigatorCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Shift)); - } - } - return showDocumentNavigatorCommand; - } + base.OnKeyDown(e); } - DocumentNavigatorWindow documentNavigatorWindow = null; - - void ShowDocumentNavigatorWindow() + protected override void OnKeyUp(KeyEventArgs e) { - HideDocumentNavigatorWindow(); - - //if (documentNavigatorWindow == null) - { - documentNavigatorWindow = new DocumentNavigatorWindow(this); - documentNavigatorWindow.Owner = Window.GetWindow(this); - } + bool isCtrlDown = Keyboard.Modifiers == ModifierKeys.Control; + bool _navigatorWindowIsVisible = navigatorWindow != null ? navigatorWindow.IsVisible : false; + Debug.WriteLine(string.Format("OnKeyUp {0} CtrlDn={1}", e.Key, isCtrlDown)); - if (MainDocumentPane == null) - return; + if (e.Key != Key.Tab || !isCtrlDown) + HideNavigatorWindow(); - Point locMainDocumentPane = MainDocumentPane.PointToScreenDPI(new Point()); - documentNavigatorWindow.Left = locMainDocumentPane.X; - documentNavigatorWindow.Top = locMainDocumentPane.Y; - documentNavigatorWindow.Width = MainDocumentPane.ActualWidth; - documentNavigatorWindow.Height = MainDocumentPane.ActualHeight; - documentNavigatorWindow.Show(); - documentNavigatorWindow.Focus(); + base.OnKeyUp(e); } - void HideDocumentNavigatorWindow() - { - //if (documentNavigatorWindow != null) - //{ - // documentNavigatorWindow.Hide(); + //void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + //{ + // if (e.Command == ShowNavigatorWindowCommand && ((Keyboard.Modifiers & ModifierKeys.Control)>0) ) + // { + // ShowNavigatorWindow(); + // e.Handled = true; + // } + // else if (e.Command == ShowDocumentNavigatorWindowCommand && ((Keyboard.Modifiers & ModifierKeys.Shift) > 0)) + // { + // ShowDocumentNavigatorWindow(); + // e.Handled = true; + // } + + //} + + //void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + //{ + // e.CanExecute = true; + //} + + + //private static RoutedUICommand showDocumentNavigatorCommand = null; + + ///// + ///// Get the command to show document navigator window + ///// + //public static RoutedUICommand ShowDocumentNavigatorWindowCommand + //{ + // get + // { + // lock (syncRoot) + // { + // if (null == showDocumentNavigatorCommand) + // { + // showDocumentNavigatorCommand = new RoutedUICommand("S_how document navigator window", "DocumentNavigator", typeof(DockingManager)); + // showDocumentNavigatorCommand.InputGestures.Add(new KeyGesture(Key.Tab, ModifierKeys.Shift)); + // } + + // } + // return showDocumentNavigatorCommand; + // } + //} + + //DocumentNavigatorWindow documentNavigatorWindow = null; + + //void ShowDocumentNavigatorWindow() + //{ + // HideDocumentNavigatorWindow(); + + // //if (documentNavigatorWindow == null) + // { + // documentNavigatorWindow = new DocumentNavigatorWindow(this); + // documentNavigatorWindow.Owner = Window.GetWindow(this); + // } + + // if (MainDocumentPane == null) + // return; + + // Point locMainDocumentPane = MainDocumentPane.PointToScreenDPI(new Point()); + // documentNavigatorWindow.Left = locMainDocumentPane.X; + // documentNavigatorWindow.Top = locMainDocumentPane.Y; + // documentNavigatorWindow.Width = MainDocumentPane.ActualWidth; + // documentNavigatorWindow.Height = MainDocumentPane.ActualHeight; + // documentNavigatorWindow.Show(); + // documentNavigatorWindow.Focus(); + //} + + //void HideDocumentNavigatorWindow() + //{ + // //if (documentNavigatorWindow != null) + // //{ + // // documentNavigatorWindow.Hide(); - // //don't close this window to be more responsive - // documentNavigatorWindow.Close(); - // documentNavigatorWindow = null; - //} - } + // // //don't close this window to be more responsive + // // documentNavigatorWindow.Close(); + // // documentNavigatorWindow = null; + // //} + //} - #endregion - + //#endregion #region DockablePane operations /// @@ -857,8 +1213,14 @@ namespace AvalonDock /// /// /// - public void Anchor(Pane paneToAnchor, AnchorStyle anchor) + public void Anchor(DockablePane paneToAnchor, AnchorStyle anchor) { + //ensure that content property is not empty + EnsureContentNotEmpty(); + + if (Content == null) + return; + //remove the pane from its original children collection FrameworkElement parentElement = paneToAnchor.Parent as FrameworkElement; @@ -883,6 +1245,12 @@ namespace AvalonDock //and insert in the top level panel if exist ResizingPanel toplevelPanel = Content as ResizingPanel; + if (toplevelPanel != null && toplevelPanel.Children.Count == 0) + { + Content = null; + toplevelPanel = null; + } + Orientation requestedOrientation = (anchor == AnchorStyle.Bottom || anchor == AnchorStyle.Top) ? Orientation.Vertical : Orientation.Horizontal; @@ -971,16 +1339,20 @@ namespace AvalonDock paneToAnchor.Focus(); + toplevelPanel.InvalidateMeasure(); } /// - /// Anchor a dockable pane () to a border of a docked pane + /// Anchor a pane ( and ) to a border of a another pane /// /// Pane to anchor /// Pane relative - /// + /// Position relative to the target pane public void Anchor(Pane paneToAnchor, Pane relativePane, AnchorStyle anchor) { + //ensure that content property is not empty + EnsureContentNotEmpty(); + if (anchor == AnchorStyle.None) anchor = AnchorStyle.Right; @@ -1003,7 +1375,9 @@ namespace AvalonDock relativePane is DocumentPane) Anchor(paneToAnchor as DocumentPane, relativePane as DocumentPane, anchor); else - Debug.Assert(false); + throw new InvalidOperationException(); + + CheckForSingleChildPanels(); } @@ -1015,6 +1389,9 @@ namespace AvalonDock /// public void Anchor(DockablePane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor) { + //ensure that content property is not empty + EnsureContentNotEmpty(); + if (anchor == AnchorStyle.None) anchor = AnchorStyle.Right; @@ -1123,6 +1500,8 @@ namespace AvalonDock } } + + relativePaneContainer.InvalidateMeasure(); #endregion @@ -1157,16 +1536,17 @@ namespace AvalonDock paneToAnchor.Focus(); } - - /// - /// Anchor a document pane () to a border of an other document pane + /// Anchor a document pane () to a border of an other document pane /// /// Pane to anchor /// Pane relative /// public void Anchor(DocumentPane paneToAnchor, DocumentPane relativePane, AnchorStyle anchor) { + //ensure that content property is not empty + EnsureContentNotEmpty(); + if (anchor == AnchorStyle.None) anchor = AnchorStyle.Right; @@ -1251,17 +1631,27 @@ namespace AvalonDock relativePaneContainer.InsertChildRelativeTo(paneToAnchor, relativePane, true); } + + if (relativePaneContainer.Orientation == Orientation.Horizontal) + { + Size desideredSize = ResizingPanel.GetEffectiveSize(paneToAnchor); + double approxStarForNewPane = desideredSize.Width / relativePaneContainer.ActualWidth; + approxStarForNewPane = Math.Min(approxStarForNewPane, 1.0); + paneToAnchor.SetValue(ResizingPanel.ResizeWidthProperty, new GridLength(approxStarForNewPane, GridUnitType.Star)); + } } + relativePaneContainer.InvalidateMeasure(); } #endregion paneToAnchor.Focus(); - (paneToAnchor.SelectedItem as ManagedContent).SetAsActive(); - if (paneToAnchor.SelectedItem is DocumentContent) - ActiveDocument = paneToAnchor.SelectedItem as DocumentContent; - + //(paneToAnchor.SelectedItem as ManagedContent).Activate(); + //if (paneToAnchor.SelectedItem is DocumentContent) + // ActiveDocument = paneToAnchor.SelectedItem as DocumentContent; + + paneToAnchor.SelectedIndex = 0; } /// @@ -1272,6 +1662,9 @@ namespace AvalonDock /// public void Anchor(DockablePane paneToAnchor, DockablePane relativePane, AnchorStyle anchor) { + //ensure that content property is not empty + EnsureContentNotEmpty(); + if (anchor == AnchorStyle.None) anchor = AnchorStyle.Right; @@ -1338,6 +1731,8 @@ namespace AvalonDock } } + + relativePaneContainer.InvalidateMeasure(); } #endregion @@ -1374,8 +1769,8 @@ namespace AvalonDock paneToAnchor.Focus(); } - - public void DropInto(Pane paneDragged, Pane paneToDropInto) + #region DropInto methods + internal void DropInto(Pane paneDragged, Pane paneToDropInto) { if (paneDragged is DockablePane && paneToDropInto is DockablePane) @@ -1387,11 +1782,9 @@ namespace AvalonDock paneToDropInto is DocumentPane) DropInto(paneDragged as DocumentPane, paneToDropInto as DocumentPane); else - Debug.Assert(false); + throw new InvalidOperationException(); } - - - public void DropInto(DocumentPane paneDragged, DocumentPane paneToDropInto) + internal void DropInto(DocumentPane paneDragged, DocumentPane paneToDropInto) { //transfer tha contents of dragged pane (conatined in a FloatingWindow) //to the pane which user select @@ -1407,13 +1800,12 @@ namespace AvalonDock paneToDropInto.SelectedIndex = 0; paneToDropInto.Focus(); if (contentToFocus != null) - contentToFocus.SetAsActive(); + contentToFocus.Activate(); } - - public void DropInto(DockablePane paneDragged, DocumentPane paneToDropInto) + internal void DropInto(DockablePane paneDragged, DocumentPane paneToDropInto) { - if (paneToDropInto != MainDocumentPane) - paneToDropInto = MainDocumentPane; + //if (paneToDropInto != MainDocumentPane) + // paneToDropInto = MainDocumentPane; //transfer contents of dragged pane (contained in a FloatingWindow) //to the pane which user select, taking care of setting contents state @@ -1433,8 +1825,7 @@ namespace AvalonDock paneToDropInto.SelectedIndex = paneToDropInto.Items.Count - 1; paneToDropInto.Focus(); } - - public void DropInto(DockablePane paneDragged, DockablePane paneToDropInto) + internal void DropInto(DockablePane paneDragged, DockablePane paneToDropInto) { //transfer tha contents of dragged pane (conatined in a FloatingWindow) //to the pane which user select, taking care of setting contents state @@ -1455,6 +1846,7 @@ namespace AvalonDock paneToDropInto.SelectedIndex = paneToDropInto.Items.Count - 1; paneToDropInto.Focus(); } + #endregion bool RemoveContentFromTabGroup(DockableContent contentToRemove) { @@ -1492,27 +1884,58 @@ namespace AvalonDock { if (group.ReferencedPane == paneToRemove) { - //foreach (DockablePaneAnchorTab tab in group.Children) - //{ - // tab.ReferencedContent.Icon = tab.Icon; - // tab.Icon = null; - //} - anchorTabPanel.Children.Remove(group); return true; } } } - return false; } + /// + /// Check if only vali panes are referenced by anchor tabs + /// + void CheckValidPanesFromTabGroups() + { + if (RestoringLayout) + return; + + foreach (var anchorTabPanel in _anchorTabPanels) + { + foreach (var group in anchorTabPanel.Children.Cast().ToArray()) + { + if (group.ReferencedPane.GetManager() != this) + { + anchorTabPanel.Children.Remove(group); + } + } + } + + if (_flyoutWindow != null && + _flyoutWindow.ReferencedPane != null && + _flyoutWindow.ReferencedPane.Items.Count == 1) + { + var cntFlyingOut = _flyoutWindow.ReferencedPane.Items[0] as ManagedContent; + if (((FlyoutDockablePane)cntFlyingOut.ContainerPane).ReferencedPane.GetManager() != this) + HideFlyoutWindow(); + } + } + + [Conditional("DEBUG")] + void CheckForSingleChildPanels() + { + //Debug.Assert(! + //new LogicalTreeAdapter(this).Descendants().Any( + // di => di.Item is ResizingPanel && ((ResizingPanel)di.Item).Children.Count == 1) + //); + } + /// /// Autohides/redock a dockable pane /// /// Pane to auto hide/redock - public void ToggleAutoHide(DockablePane pane) + internal void ToggleAutoHide(DockablePane pane) { if (!_OnApplyTemplateFlag) { @@ -1533,7 +1956,7 @@ namespace AvalonDock _flyoutWindow.ReferencedPane.Items.Count > 0 ? _flyoutWindow.ReferencedPane.Items[0] as DockableContent : pane.Items[0] as DockableContent; - HideAutoHideWindow(); + HideFlyoutWindow(); ResizingPanel parentPanel = pane.Parent as ResizingPanel; if (parentPanel != null && parentPanel.Children.Count >= 3) @@ -1568,8 +1991,8 @@ namespace AvalonDock { DockablePaneAnchorTab tab = new DockablePaneAnchorTab(); tab.ReferencedContent = content; - tab.Anchor = pane.Anchor; - tab.Icon = content.Icon; + //tab.Anchor = pane.Anchor; + //tab.Icon = content.Icon; group.Children.Add(tab); @@ -1614,39 +2037,70 @@ namespace AvalonDock #endregion - #region Hide/Show contents - List _hiddenContents = new List(); -#if DEBUG - internal void CheckHiddenState(DockableContent contentToCheck) - { - if (contentToCheck.State == DockableContentState.Hidden) - Debug.Assert(_hiddenContents.Contains(contentToCheck)); - else - Debug.Assert(!_hiddenContents.Contains(contentToCheck)); - } -#endif +// #region HiddenContents + +// /// +// /// HiddenContents Read-Only Dependency Property +// /// +// private static readonly DependencyPropertyKey HiddenContentsPropertyKey +// = DependencyProperty.RegisterReadOnly("HiddenContents", typeof(ManagedContentCollection), typeof(DockingManager), +// new FrameworkPropertyMetadata((ManagedContentCollection)null)); + +// public static readonly DependencyProperty HiddenContentsProperty +// = HiddenContentsPropertyKey.DependencyProperty; + +// /// +// /// Gets the HiddenContents property. This dependency property +// /// returns the list of object that are in hidden state. +// /// +// public ManagedContentCollection HiddenContents +// { +// get { return (ManagedContentCollection)GetValue(HiddenContentsProperty); } +// protected set { SetValue(HiddenContentsPropertyKey, value); } +// } + +// #endregion + +//#if DEBUG +// internal void CheckHiddenState(DockableContent contentToCheck) +// { +// if (contentToCheck.State == DockableContentState.Hidden) +// Debug.Assert(HiddenContents.Contains(contentToCheck)); +// else +// Debug.Assert(!HiddenContents.Contains(contentToCheck)); +// } +//#endif + /// /// Hide a dockable content removing it from its container /// /// Content to hide /// Note that if you simply remove a content from its container without calling this method, the /// layout serializer component can't managed correctly the removed content. - public void Hide(DockableContent content) + internal void Hide(DockableContent content) { if (content.State == DockableContentState.Hidden) + { + DockableContents.Add(content); return; + } if (!content.IsCloseable) return; - content.SaveCurrentStateAndPosition(); + if (content.State != DockableContentState.FloatingWindow && + content.State != DockableContentState.DockableWindow) + { + //save position only if hiding from a docked or autohidden pane + content.SaveCurrentStateAndPosition(); + } if (content.State == DockableContentState.AutoHide) { - HideAutoHideWindow(); + HideFlyoutWindow(); RemoveContentFromTabGroup(content); } @@ -1656,25 +2110,19 @@ namespace AvalonDock DockableFloatingWindow floatingWindow = Window.GetWindow(content) as DockableFloatingWindow; if (floatingWindow != null && - floatingWindow.HostedPane.HasSingleItem) + (floatingWindow.Content as Pane).HasSingleItem && + !floatingWindow.IsClosing) { floatingWindow.Close(); } - - content.DetachFromContainerPane(); - } - else - { - content.DetachFromContainerPane(); } - if (content.State != DockableContentState.Hidden) { - content.SetStateToHidden(); + DockableContents.Add(content); - Debug.Assert(!_hiddenContents.Contains(content)); - _hiddenContents.Add(content); + content.SetStateToHidden(); + content.DetachFromContainerPane(); } if (ActiveDocument == content) @@ -1690,51 +2138,83 @@ namespace AvalonDock /// Document to show/add. /// If document provided is not present in the list, this method inserts it in first position of collection. /// In both cases select it in the container . - public void Show(DocumentContent document) + internal void Show(DocumentContent document) { - bool found = false; - foreach (DocumentContent doc in Documents) + bool found = Documents.FirstOrDefault(d => d == document) != null; + + if (!found && MainDocumentPane != null) { - if (doc == document) + if (document.Parent is DocumentPane) { - found = true; - break; + ((DocumentPane)document.Parent).Items.Clear(); } + + MainDocumentPane.Items.Insert(0, document); } + } + + /// + /// Show or add a document in AvalonDock + /// + /// Document to show/add. + /// Indicates if the document should be placed in a floating window + /// If document provided is not present in the list, this method inserts it in first position of collection. + /// In both cases select it in the container . + internal void Show(DocumentContent document, bool floating) + { + bool found = Documents.FirstOrDefault(d => d == document) != null; + if (!found && MainDocumentPane != null) { if (document.Parent is DocumentPane) { ((DocumentPane)document.Parent).Items.Clear(); } - //if (document.Parent != null) - //{ - // throw new InvalidProgramException( - // string.Format("Disconnnect first the document from its logical parent ({0})", - // document.Parent.GetType())); - //} - MainDocumentPane.Items.Insert(0, document); + if (floating) + { + DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this); + floatingWindow.Content = document; + floatingWindow.Show(); + } + else + MainDocumentPane.Items.Insert(0, document); } + else if (found && document.ContainerPane is FloatingDocumentPane) + { + var containerPane = document.ContainerPane as FloatingDocumentPane; + DocumentPane previousPane = containerPane.PreviousPane; + int arrayIndexPreviuosPane = containerPane.ArrayIndexPreviousPane; + //if previous pane exist that redock to it + if (previousPane == null || + previousPane.GetManager() != this) + { + previousPane = MainDocumentPane; + arrayIndexPreviuosPane = 0; + } + + if (previousPane != null) + { + if (arrayIndexPreviuosPane > previousPane.Items.Count) + arrayIndexPreviuosPane = previousPane.Items.Count; - //DocumentPane docPane = document.ContainerPane as DocumentPane; + previousPane.Items.Insert(arrayIndexPreviuosPane, + containerPane.RemoveContent(0)); + } + + containerPane.FloatingWindow.Close(); + } - //if (docPane != null) - //{ - // docPane.SelectedItem = document; - // if (document.Content is IInputElement) - // Keyboard.Focus(document.Content as IInputElement); - //} - document.SetAsActive(); } /// /// Show a dockable content in its container /// /// Content to show - public void Show(DockableContent content) + internal void Show(DockableContent content) { + //if desideredState is not defined, use the saved state if exists if (content.SavedStateAndPosition != null) Show(content, content.SavedStateAndPosition.State); else @@ -1746,7 +2226,7 @@ namespace AvalonDock /// /// Content to show /// State desidered - public void Show(DockableContent content, DockableContentState desideredState) + internal void Show(DockableContent content, DockableContentState desideredState) { Show(content, desideredState, AnchorStyle.None); } @@ -1758,8 +2238,10 @@ namespace AvalonDock /// State desidered /// Border to which anchor the newly created container pane /// - public void Show(DockableContent content, DockableContentState desideredState, AnchorStyle desideredAnchor) + internal void Show(DockableContent content, DockableContentState desideredState, AnchorStyle desideredAnchor) { + Debug.WriteLine(string.Format("Show Content={0}, desideredState={1}, desideredAnchor={2}", content.Name, desideredState, desideredAnchor)); + #region Dockable content if (desideredState == DockableContentState.Hidden)//??!!show hidden? @@ -1767,20 +2249,40 @@ namespace AvalonDock if (content.State == DockableContentState.AutoHide) { - ShowFlyoutWindow(content); + //first redock the content + (content.ContainerPane as DockablePane).ToggleAutoHide(); + //then show it as desidered + Show(content, desideredState, desideredAnchor); } else if (content.State == DockableContentState.Docked || - content.State == DockableContentState.Document) + content.State == DockableContentState.Document || + content.State == DockableContentState.None) { - if (content.ContainerPane == null) + if (content.ContainerPane == null || + content.State == DockableContentState.None) { //Problem!? try to rescue - if (content.State == DockableContentState.Docked) + if (content.State == DockableContentState.Docked || + content.State == DockableContentState.None) { //find the the pane which the desidered anchor style - DockablePane foundPane = this.FindChildDockablePane(desideredAnchor); + //DockablePane foundPane = this.FindChildDockablePane(desideredAnchor != AnchorStyle.None ? desideredAnchor : AnchorStyle.Right); + //first search for a pane with other contents (avoiding empty panes which are containers for hidden contents) + ILinqToTree itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).IsDocked); + + if (itemFound == null)//search for all panes (even empty) + itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).Items.Count == 0); + + DockablePane foundPane = itemFound != null ? itemFound.Item as DockablePane : null; + if (foundPane != null) + { + content.SetStateToDock(); foundPane.Items.Add(content); + var containerPanel = foundPane.Parent as ResizingPanel; + if (containerPanel != null) + containerPanel.InvalidateMeasure(); + } else { //if no suitable pane was found create e new one on the fly @@ -1805,39 +2307,45 @@ namespace AvalonDock { ((Panel)content.ContainerPane.Parent).Children.Remove(content.ContainerPane); } - Anchor(content.ContainerPane, desideredAnchor); + + Anchor(content.ContainerPane as DockablePane, desideredAnchor); } if (desideredState == DockableContentState.DockableWindow || desideredState == DockableContentState.FloatingWindow) { - DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, content); - floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; - floatingWindow.Owner = Window.GetWindow(this); + var floatingWindow = new DockableFloatingWindow(this); + floatingWindow.Content = content; + + var mainWindow = Window.GetWindow(this); + if (mainWindow.IsVisible) + floatingWindow.Owner = mainWindow; + + //floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; //if (content.Content != null) //{ // floatingWindow.Width = Math.Min(((FrameworkElement)content.Content).ActualWidth, ResizingPanel.GetResizeWidth(content.ContainerPane)); // floatingWindow.Height = Math.Min(((FrameworkElement)content.Content).ActualHeight, ResizingPanel.GetResizeHeight(content.ContainerPane)); //} //else - //{ - floatingWindow.Width = 400; - floatingWindow.Height = 400; + ////{ + // floatingWindow.Width = 400; + // floatingWindow.Height = 400; //} - RegisterFloatingWindow(floatingWindow); + floatingWindow.Show(); + } else if (desideredState == DockableContentState.AutoHide) { - if (content.ContainerPane != null) - content.ContainerPane.SelectedItem = this; - //content.FocusContent(); - //if (content.Content is IInputElement) - // Keyboard.Focus(content.Content as IInputElement); - content.SetAsActive(); + var paneContainer = content.ContainerPane as DockablePane; + Debug.Assert(paneContainer != null); - DockablePane.ToggleAutoHideCommand.Execute(null, content.ContainerPane); + if (paneContainer != null) + paneContainer.ToggleAutoHide(); + + content.Activate(); } else if (desideredState == DockableContentState.Document) { @@ -1852,7 +2360,7 @@ namespace AvalonDock else { content.ContainerPane.SelectedItem = content; - content.SetAsActive(); + content.Activate(); DockablePane dockParent = content.ContainerPane as DockablePane; if (content.ActualWidth == 0.0 && ( @@ -1867,48 +2375,33 @@ namespace AvalonDock ResizingPanel.SetResizeWidth(dockParent, new GridLength(200)); ResizingPanel.SetEffectiveSize(dockParent, new Size(200, 0.0)); } - - - //ActiveContent = content; - ////content.FocusContent(); - //if (content.Content is IInputElement) - // Keyboard.Focus(content.Content as IInputElement); - } - } - else if ( - content.State == DockableContentState.DockableWindow || - content.State == DockableContentState.FloatingWindow) - { - FloatingDockablePane containerPane = content.ContainerPane as FloatingDockablePane; - - if (containerPane != null) - { - //check if visible on the primary screen - if (containerPane.FloatingWindow.Left > System.Windows.SystemParameters.PrimaryScreenWidth) - containerPane.FloatingWindow.Left = System.Windows.SystemParameters.PrimaryScreenWidth - containerPane.FloatingWindow.Width; - if (containerPane.FloatingWindow.Top > System.Windows.SystemParameters.PrimaryScreenHeight) - containerPane.FloatingWindow.Top = System.Windows.SystemParameters.PrimaryScreenHeight - containerPane.FloatingWindow.Height; - - - containerPane.FloatingWindow.Activate(); } - } else if (content.State == DockableContentState.Document) { if (content.ContainerPane != null) content.ContainerPane.SelectedItem = this; - //content.FocusContent(); - //if (content.Content is IInputElement) - // Keyboard.Focus(content.Content as IInputElement); - content.SetAsActive(); + content.Activate(); } - else if (content.State == DockableContentState.Hidden) + else if (content.State == DockableContentState.Hidden || + content.State == DockableContentState.DockableWindow || + content.State == DockableContentState.FloatingWindow) { - Debug.Assert(_hiddenContents.Contains(content)); + if (content.State == DockableContentState.Hidden) + { + //Debug.Assert(HiddenContents.Contains(content)); + //HiddenContents.Remove(content); + } + else + { + FloatingWindow floatingWindow = null; + floatingWindow = (content.ContainerPane as FloatingDockablePane).FloatingWindow; + content.DetachFromContainerPane(); - _hiddenContents.Remove(content); + if (floatingWindow.HostedPane.Items.Count == 0) + floatingWindow.Close(); + } if (desideredState == DockableContentState.Docked || desideredState == DockableContentState.AutoHide) @@ -1922,6 +2415,7 @@ namespace AvalonDock { //ok previous container pane is here.. Pane prevPane = content.SavedStateAndPosition.ContainerPane; + if (content.SavedStateAndPosition.ChildIndex < prevPane.Items.Count) { prevPane.Items.Insert(content.SavedStateAndPosition.ChildIndex, content); @@ -1931,14 +2425,29 @@ namespace AvalonDock prevPane.Items.Add(content); } - prevPane.SelectedItem = content; + if (prevPane.Items.Count == 1) + { + if (!double.IsNaN(content.SavedStateAndPosition.Width) || + !double.IsInfinity(content.SavedStateAndPosition.Width)) + { + ResizingPanel.SetResizeWidth(content, + new GridLength(content.SavedStateAndPosition.Width)); + } + } + + DockablePane prevDockablePane = prevPane as DockablePane; + if (prevDockablePane != null && prevDockablePane.IsAutoHidden) + { + prevDockablePane.ToggleAutoHide(); + } + content.SetStateToDock(); + content.Activate(); + + (prevPane.Parent as UIElement).InvalidateMeasure(); } else { - DockablePane newHostpane = new DockablePane(); - newHostpane.Items.Add(content); - if (desideredAnchor == AnchorStyle.None && content.SavedStateAndPosition != null && content.SavedStateAndPosition.Anchor != AnchorStyle.None) @@ -1947,37 +2456,65 @@ namespace AvalonDock if (desideredAnchor == AnchorStyle.None) desideredAnchor = AnchorStyle.Right; - if (desideredAnchor == AnchorStyle.Left || - desideredAnchor == AnchorStyle.Right) + DockablePane foundPane = null; + + if (desideredState == DockableContentState.Docked) + { + //first not empty panes + ILinqToTree itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).IsDocked); + + if (itemFound == null)//look for all panes even empty + itemFound = new LogicalTreeAdapter(this).Descendants().FirstOrDefault(el => el.Item is DockablePane && (el.Item as DockablePane).Anchor == desideredAnchor && (el.Item as DockablePane).Items.Count == 0); + + foundPane = itemFound != null ? itemFound.Item as DockablePane : null; + } + + if (foundPane != null) { - double w = 200; - if (content.SavedStateAndPosition != null && - !double.IsInfinity(content.SavedStateAndPosition.Width) && - !double.IsNaN(content.SavedStateAndPosition.Width)) - w = content.SavedStateAndPosition.Width; - - ResizingPanel.SetResizeWidth(newHostpane, new GridLength(w)); - ResizingPanel.SetEffectiveSize(newHostpane, new Size(w, 0.0)); + content.SetStateToDock(); + foundPane.Items.Add(content); + + if ((foundPane.IsAutoHidden && desideredState == DockableContentState.Docked) || + (!foundPane.IsAutoHidden && desideredState == DockableContentState.AutoHide)) + foundPane.ToggleAutoHide(); } else { - double h = 200; - if (content.SavedStateAndPosition != null && - !double.IsInfinity(content.SavedStateAndPosition.Height) && - !double.IsNaN(content.SavedStateAndPosition.Height)) - h = content.SavedStateAndPosition.Height; - - ResizingPanel.SetResizeHeight(newHostpane, new GridLength(h)); - ResizingPanel.SetEffectiveSize(newHostpane, new Size(0.0, h)); - } + DockablePane newHostpane = new DockablePane(); + newHostpane.Items.Add(content); + + if (desideredAnchor == AnchorStyle.Left || + desideredAnchor == AnchorStyle.Right) + { + double w = 200; + if (content.SavedStateAndPosition != null && + !double.IsInfinity(content.SavedStateAndPosition.Width) && + !double.IsNaN(content.SavedStateAndPosition.Width)) + w = content.SavedStateAndPosition.Width; + + ResizingPanel.SetResizeWidth(newHostpane, new GridLength(w)); + ResizingPanel.SetEffectiveSize(newHostpane, new Size(w, 0.0)); + } + else + { + double h = 200; + if (content.SavedStateAndPosition != null && + !double.IsInfinity(content.SavedStateAndPosition.Height) && + !double.IsNaN(content.SavedStateAndPosition.Height)) + h = content.SavedStateAndPosition.Height; + + ResizingPanel.SetResizeHeight(newHostpane, new GridLength(h)); + ResizingPanel.SetEffectiveSize(newHostpane, new Size(0.0, h)); + } - Anchor(newHostpane, desideredAnchor); - if (desideredState == DockableContentState.AutoHide) - { - DockablePane.ToggleAutoHideCommand.Execute(null, newHostpane); - } + Anchor(newHostpane, desideredAnchor); + if (desideredState == DockableContentState.AutoHide) + { + ToggleAutoHide(newHostpane); + } + } } ActiveContent = content; @@ -1995,32 +2532,74 @@ namespace AvalonDock } else { - newHostpane = new DockablePane(); + newHostpane = new DockablePane(); newHostpane.Items.Add(content); + } - content.SetStateToDock(); + if (desideredState == DockableContentState.DockableWindow) + content.SetStateToDockableWindow(); + else if (desideredState == DockableContentState.FloatingWindow) + content.SetStateToFloatingWindow(); if (prevHostpane != null) { - DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, content); - floatingWindow.WindowStartupLocation = WindowStartupLocation.Manual; - floatingWindow.Top = prevHostpane.FloatingWindow.Top; - floatingWindow.Left = prevHostpane.FloatingWindow.Left; - floatingWindow.Width = prevHostpane.FloatingWindow.Width; - floatingWindow.Height = prevHostpane.FloatingWindow.Height; - floatingWindow.Owner = Window.GetWindow(this); - RegisterFloatingWindow(floatingWindow); - floatingWindow.Show(); + //check to see if floating window that host prevHostPane is already loaded (hosting other contents) + var floatingWindow = prevHostpane.Parent as DockableFloatingWindow; + if (floatingWindow != null && floatingWindow.IsLoaded) + { + floatingWindow.Activate(); + } + else + { + floatingWindow = new DockableFloatingWindow(this); + floatingWindow.Content = content; + floatingWindow.WindowStartupLocation = WindowStartupLocation.Manual; + floatingWindow.Top = prevHostpane.FloatingWindow.Top; + floatingWindow.Left = prevHostpane.FloatingWindow.Left; + floatingWindow.Width = prevHostpane.FloatingWindow.Width; + floatingWindow.Height = prevHostpane.FloatingWindow.Height; + //floatingWindow.Owner = Window.GetWindow(this); + var mainWindow = Window.GetWindow(this); + if (mainWindow.IsVisible) + floatingWindow.Owner = mainWindow; + + + + //now I've created a new pane to host the hidden content + //if a an hidden content is shown that has prevHostpane as saved pane + //I want that it is relocated in this new pane that I've created right now + var hiddenContents = DockableContents.Where(c => c.State == DockableContentState.Hidden).ToArray(); + foreach (var hiddenContent in hiddenContents) + { + if (hiddenContent.SavedStateAndPosition.ContainerPane == prevHostpane) + { + hiddenContent.SavedStateAndPosition = new DockableContentStateAndPosition( + (floatingWindow.Content as Pane), + hiddenContent.SavedStateAndPosition.ChildIndex, + hiddenContent.SavedStateAndPosition.Width, + hiddenContent.SavedStateAndPosition.Height, + hiddenContent.SavedStateAndPosition.Anchor, + hiddenContent.SavedStateAndPosition.State); + } + } + + floatingWindow.Show(); + } } else if (newHostpane != null) { - DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, newHostpane); + var floatingWindow = new DockableFloatingWindow(this); + floatingWindow.Content = newHostpane; floatingWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen; floatingWindow.Width = 200; floatingWindow.Height = 500; - floatingWindow.Owner = Window.GetWindow(this); - RegisterFloatingWindow(floatingWindow); + //floatingWindow.Owner = Window.GetWindow(this); + var mainWindow = Window.GetWindow(this); + if (mainWindow.IsVisible) + floatingWindow.Owner = mainWindow; + + floatingWindow.Show(); } @@ -2039,9 +2618,9 @@ namespace AvalonDock #endregion -#if DEBUG - CheckHiddenState(content); -#endif +//#if DEBUG +// CheckHiddenState(content); +//#endif } #endregion @@ -2126,12 +2705,41 @@ namespace AvalonDock #region Flyout window + /// + /// Stores the only one flyout window that can be open at time + /// FlyoutPaneWindow _flyoutWindow = null; + + /// + /// This object is used to handle interop events (i.e. WindowsPosChanging) of the main window the contains this + /// DockingManager object + /// + /// WindowsPosChanging are useful to automatically resize the FlyoutWindow when user move + /// the main window. WindowInteropWrapper _wndInteropWrapper = null; - void HideAutoHideWindow() + + /// + /// Gets or sets a value indicating if flyout windows should animate when are open or closed + /// + public bool IsAnimationEnabled + { + get { return (bool)GetValue(IsAnimationEnabledProperty); } + set { SetValue(IsAnimationEnabledProperty, value); } + } + + // Using a DependencyProperty as the backing store for IsAnimationEnabled. This enables animation, styling, binding, etc... + public static readonly DependencyProperty IsAnimationEnabledProperty = + DependencyProperty.Register("IsAnimationEnabled", typeof(bool), typeof(DockingManager), new UIPropertyMetadata(false)); + + + + /// + /// Closes the flyout window + /// + void HideFlyoutWindow() { - if (_flyoutWindow != null) + if (_flyoutWindow != null && !_flyoutWindow.IsClosing) { _flyoutWindow.Height = 0.0; _flyoutWindow.Width = 0.0; @@ -2140,25 +2748,30 @@ namespace AvalonDock } } - - internal void ShowFlyoutWindow(DockableContent content) + /// + /// Shows a flyout window for a content + /// + /// Content to show + internal void ShowFlyoutWindow(DockableContent content, DockablePaneAnchorTab tabActivating) { //check if parent window is Active Window parentWindow = Window.GetWindow(this); - if (parentWindow == null) + if (parentWindow == null || !parentWindow.IsVisible) return; if (!parentWindow.IsActive && (_flyoutWindow == null || !_flyoutWindow.IsActive)) return; - //check if content is already visible in a flyout window if (_flyoutWindow != null && _flyoutWindow.ReferencedPane.Items.Contains(content)) + { + //continue to show the winow + //_flyoutWindow.KeepWindowOpen(); return; - + } //hide previous create window - HideAutoHideWindow(); + HideFlyoutWindow(); //select this content in the referenced pane content.ContainerPane.SelectedItem = content; @@ -2166,63 +2779,78 @@ namespace AvalonDock if (_wndInteropWrapper == null) { - _wndInteropWrapper = new WindowInteropWrapper(); - _wndInteropWrapper.OnWindowPosChanging+=new EventHandler(_wndInteropWrapper_OnWindowPosChanging); + _wndInteropWrapper = new WindowInteropWrapper(parentWindow); + _wndInteropWrapper.WindowPosChanging += (s, e) => + { + //update the flyout window + UpdateFlyoutWindowPosition(); + }; } - _wndInteropWrapper.AttachedObject = parentWindow; //create e new window _flyoutWindow = new FlyoutPaneWindow(this, content); _flyoutWindow.Owner = parentWindow; _flyoutWindow.FlowDirection = this.FlowDirection; - + _flyoutWindow.ShowActivated = false; + _flyoutWindow.AnchorTabActivating = tabActivating; + UpdateFlyoutWindowPosition(true); - _flyoutWindow.Closing += new System.ComponentModel.CancelEventHandler(_flyoutWindow_Closing); + _flyoutWindow.Closing += new System.ComponentModel.CancelEventHandler(OnFlyoutWindowClosing); _flyoutWindow.Show(); //this.Focus(); } + /// + /// Handles the resize changed event to update location and size of the flyout window + /// + /// protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) { UpdateFlyoutWindowPosition(); base.OnRenderSizeChanged(sizeInfo); } - - void _flyoutWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) + /// + /// Handle the closing event of the flyout window to reset internal variables + /// + /// + /// + void OnFlyoutWindowClosing(object sender, System.ComponentModel.CancelEventArgs e) { - _flyoutWindow.Closing -= new System.ComponentModel.CancelEventHandler(_flyoutWindow_Closing); + _flyoutWindow.Closing -= new System.ComponentModel.CancelEventHandler(OnFlyoutWindowClosing); _flyoutWindow.Owner = null; - _wndInteropWrapper.AttachedObject = null; } + /// + /// Update location and size of the flyout window + /// void UpdateFlyoutWindowPosition() { UpdateFlyoutWindowPosition(false); } + /// + /// Update location and size of the flyout window + /// + /// Indicates if thw current flyout window should be setup for the first time. void UpdateFlyoutWindowPosition(bool initialSetup) { if (_flyoutWindow == null) return; - - Debug.WriteLine("_leftAnchorTabPanel " + _leftAnchorTabPanel.ActualWidth + " - " + _leftAnchorTabPanel.Children.Count); - + double leftTabsWidth = FlowDirection == FlowDirection.LeftToRight ? _leftAnchorTabPanel.ActualWidth : _rightAnchorTabPanel.ActualWidth; double rightTabsWidth = FlowDirection == FlowDirection.LeftToRight ? _rightAnchorTabPanel.ActualWidth : _leftAnchorTabPanel.ActualWidth; double topTabsHeight = _topAnchorTabPanel.ActualHeight; double bottomTabsHeight = _bottomAnchorTabPanel.ActualHeight; Point locDockingManager = HelperFunc.PointToScreenWithoutFlowDirection(this, new Point()); + Point locContent = HelperFunc.PointToScreenWithoutFlowDirection(Content as FrameworkElement, new Point()); + double resWidth = initialSetup ? ResizingPanel.GetResizeWidth(_flyoutWindow.ReferencedPane).Value : _flyoutWindow.Width; double resHeight = initialSetup ? ResizingPanel.GetResizeHeight(_flyoutWindow.ReferencedPane).Value : _flyoutWindow.Height; - //double resWidth = initialSetup ? ResizingPanel.GetEffectiveSize(_flyoutWindow.ReferencedPane).Width : _flyoutWindow.Width; - //double resHeight = initialSetup ? ResizingPanel.GetEffectiveSize(_flyoutWindow.ReferencedPane).Height : _flyoutWindow.Height; - _flyoutWindow.MinLeft = locDockingManager.X; - _flyoutWindow.MinTop = locDockingManager.Y; if (_flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Right) { @@ -2247,10 +2875,13 @@ namespace AvalonDock if (_flyoutWindow.ReferencedPane.Anchor == AnchorStyle.Left) { _flyoutWindow.Top = locDockingManager.Y + topTabsHeight; + //_flyoutWindow.Top = locContent.Y; _flyoutWindow.Height = this.ActualHeight - topTabsHeight - bottomTabsHeight; + //_flyoutWindow.Height = ((FrameworkElement)this.Content).ActualHeight; _flyoutWindow.MaxWidth = ActualWidth - leftTabsWidth; _flyoutWindow.MaxHeight = ActualHeight; + if (initialSetup) { @@ -2307,13 +2938,9 @@ namespace AvalonDock } if (_flyoutWindow != null && !_flyoutWindow.IsClosing) - _flyoutWindow.UpdateClipRegion(); + _flyoutWindow.UpdatePositionAndSize(); } - void _wndInteropWrapper_OnWindowPosChanging(object sender, EventArgs e) - { - UpdateFlyoutWindowPosition(); - } #endregion @@ -2348,7 +2975,8 @@ namespace AvalonDock { if (CaptureMouse()) { - DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this, documentContent); + DocumentFloatingWindow floatingWindow = new DocumentFloatingWindow(this); + floatingWindow.Content = documentContent; Drag(floatingWindow, point, offset); } @@ -2359,9 +2987,9 @@ namespace AvalonDock { if (CaptureMouse()) { - DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, dockableContent); + var floatingWindow = new DockableFloatingWindow(this); + floatingWindow.Content = dockableContent; floatingWindow.Owner = Window.GetWindow(this); - RegisterFloatingWindow(floatingWindow); Drag(floatingWindow, point, offset); } } @@ -2371,9 +2999,9 @@ namespace AvalonDock { if (CaptureMouse()) { - DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this, dockablePane); + DockableFloatingWindow floatingWindow = new DockableFloatingWindow(this); + floatingWindow.Content = dockablePane; floatingWindow.Owner = Window.GetWindow(this); - RegisterFloatingWindow(floatingWindow); Drag(floatingWindow, point, offset); } } @@ -2386,7 +3014,7 @@ namespace AvalonDock DragPaneServices.MoveDrag(this.PointToScreenDPI(e.GetPosition(this))); if (_flyoutWindow != null) - _flyoutWindow.UpdateClipRegion(); + _flyoutWindow.UpdatePositionAndSize(); } base.OnMouseMove(e); @@ -2424,6 +3052,9 @@ namespace AvalonDock { get { + if (DesignerProperties.GetIsInDesignMode(this)) + return null; + if (_dragPaneServices == null) _dragPaneServices = new DragPaneServices(this); @@ -2432,9 +3063,8 @@ namespace AvalonDock } #endregion - #region IDropSurface - public bool IsSurfaceVisible + bool IDropSurface.IsSurfaceVisible { get { @@ -2446,7 +3076,7 @@ namespace AvalonDock /// /// Returns a rectangle where this surface is active /// - public Rect SurfaceRectangle + Rect IDropSurface.SurfaceRectangle { get { @@ -2468,6 +3098,9 @@ namespace AvalonDock { get { + if (DesignerProperties.GetIsInDesignMode(this)) + throw new NotSupportedException("OverlayWindow not valid in design mode"); + if (_overlayWindow == null) _overlayWindow = new OverlayWindow(this); @@ -2479,7 +3112,7 @@ namespace AvalonDock /// Handles this sourface mouse entering (show current overlay window) /// /// Current mouse position - public void OnDragEnter(Point point) + void IDropSurface.OnDragEnter(Point point) { if (OverlayWindow.IsVisible) return; @@ -2500,7 +3133,7 @@ namespace AvalonDock /// Handles mouse overing this surface /// /// - public void OnDragOver(Point point) + void IDropSurface.OnDragOver(Point point) { } @@ -2509,13 +3142,13 @@ namespace AvalonDock /// Handles mouse leave event during drag (hide overlay window) /// /// - public void OnDragLeave(Point point) + void IDropSurface.OnDragLeave(Point point) { OverlayWindow.Owner = null; OverlayWindow.Hide(); - Window mainWindow = Window.GetWindow(this); - if (mainWindow != null) - mainWindow.Activate(); + //Window mainWindow = Window.GetWindow(this); + //if (mainWindow != null) + // mainWindow.Activate(); } /// @@ -2523,14 +3156,13 @@ namespace AvalonDock /// /// Current mouse position /// Returns alwasy false because this surface doesn't support direct drop - public bool OnDrop(Point point) + bool IDropSurface.OnDrop(Point point) { return false; } #endregion - #region INotifyPropertyChanged Members public event PropertyChangedEventHandler PropertyChanged; @@ -2542,26 +3174,27 @@ namespace AvalonDock } #endregion - #region Persistence void SaveLayout(XmlWriter xmlWriter, DockablePane pane) { - if (pane.Items.Count > 0) + bool needToSavePane = pane.Items.Count > 0; + + //if a pane is reference by a content than save it + if (DockableContents.FirstOrDefault(d => d.SavedStateAndPosition != null && d.SavedStateAndPosition.ContainerPane == pane) != null) + needToSavePane = true; + + if (needToSavePane) { xmlWriter.WriteStartElement("DockablePane"); - //if (!double.IsInfinity(ResizingPanel.GetResizeWidth(pane))) - // xmlWriter.WriteAttributeString("ResizeWidth", XmlConvert.ToString(ResizingPanel.GetResizeWidth(pane))); - ////if (!double.IsInfinity(ResizingPanel.GetResizeHeight(pane))) - // xmlWriter.WriteAttributeString("ResizeHeight", XmlConvert.ToString(ResizingPanel.GetResizeHeight(pane))); xmlWriter.WriteAttributeString("ResizeWidth", ResizingPanel.GetResizeWidth(pane).ToString()); xmlWriter.WriteAttributeString("ResizeHeight", ResizingPanel.GetResizeHeight(pane).ToString()); xmlWriter.WriteAttributeString("EffectiveSize", new SizeConverter().ConvertToInvariantString(ResizingPanel.GetEffectiveSize(pane))); - + xmlWriter.WriteAttributeString("ID", pane.ID.ToString()); xmlWriter.WriteAttributeString("Anchor", pane.Anchor.ToString()); - Debug.Assert(pane.Items.Count > 0); + xmlWriter.WriteAttributeString("IsAutoHidden", XmlConvert.ToString(pane.IsAutoHidden)); foreach (DockableContent content in pane.Items) { @@ -2584,7 +3217,7 @@ namespace AvalonDock xmlWriter.WriteAttributeString("Height", XmlConvert.ToString(flWindow.Height)); - SaveLayout(xmlWriter, flWindow.HostedPane); + SaveLayout(xmlWriter, flWindow.HostedPane as DockablePane); xmlWriter.WriteEndElement(); } @@ -2601,7 +3234,21 @@ namespace AvalonDock xmlWriter.WriteStartElement("DockableContent"); xmlWriter.WriteAttributeString("Name", content.Name); - xmlWriter.WriteAttributeString("AutoHide", XmlConvert.ToString(content.State == DockableContentState.AutoHide)); + //xmlWriter.WriteAttributeString("AutoHide", XmlConvert.ToString(content.State == DockableContentState.AutoHide)); + + content.SaveLayout(xmlWriter); + + xmlWriter.WriteEndElement(); + } + } + + void SaveLayout(XmlWriter xmlWriter, DocumentContent content) + { + if (!string.IsNullOrEmpty(content.Name)) + { + xmlWriter.WriteStartElement("DocumentContent"); + + xmlWriter.WriteAttributeString("Name", content.Name); content.SaveLayout(xmlWriter); @@ -2611,39 +3258,54 @@ namespace AvalonDock void SaveLayout(XmlWriter xmlWriter, DocumentPane pane) { - xmlWriter.WriteStartElement("DocumentPanePlaceHolder"); + if (pane.Items.Count == 0 && !pane.IsMainDocumentPane.GetValueOrDefault()) + return; + + xmlWriter.WriteStartElement("DocumentPane"); + + if (pane.IsMainDocumentPane.GetValueOrDefault()) + xmlWriter.WriteAttributeString("IsMain", "true"); foreach (ManagedContent content in pane.Items) { if (content is DockableContent) { - DockableContent dockableContent = content as DockableContent; + var dockableContent = content as DockableContent; SaveLayout(xmlWriter, dockableContent); } + else if (content is DocumentContent) + { + var documentContent = content as DocumentContent; + SaveLayout(xmlWriter, documentContent); + } } xmlWriter.WriteEndElement(); } - void SaveLayout(XmlWriter xmlWriter, DocumentPaneResizingPanel panelToSerialize) - { - xmlWriter.WriteStartElement("DocumentPanePlaceHolder"); + //void SaveLayout(XmlWriter xmlWriter, DocumentPaneResizingPanel panelToSerialize) + //{ + // xmlWriter.WriteStartElement("DocumentPanePlaceHolder"); - List listOfFoundContents = new List(); - FindContents(listOfFoundContents, panelToSerialize); + // //List listOfFoundContents = new List(); + // //FindContents(listOfFoundContents, panelToSerialize); + // var listOfFoundContents = new LogicalTreeAdapter(panelToSerialize).Descendants().Where(i => i.Item is DockableContent).Select(i => i.Item); - foreach (DockableContent content in listOfFoundContents) - { - SaveLayout(xmlWriter, content); - } + // foreach (DockableContent content in listOfFoundContents) + // { + // SaveLayout(xmlWriter, content); + // } - xmlWriter.WriteEndElement(); - } + // xmlWriter.WriteEndElement(); + //} void SaveLayout(XmlWriter xmlWriter, ResizingPanel panelToSerialize) { - xmlWriter.WriteStartElement("ResizingPanel"); + if (panelToSerialize is DocumentPaneResizingPanel) + xmlWriter.WriteStartElement("DocumentPaneResizingPanel"); + else + xmlWriter.WriteStartElement("ResizingPanel"); //if (!double.IsInfinity(ResizingPanel.GetResizeWidth(panelToSerialize))) // xmlWriter.WriteAttributeString("ResizeWidth", XmlConvert.ToString(ResizingPanel.GetResizeWidth(panelToSerialize))); @@ -2663,8 +3325,8 @@ namespace AvalonDock SaveLayout(xmlWriter, child as DockablePane); else if (child is DocumentPane) SaveLayout(xmlWriter, child as DocumentPane); - else if (child is DocumentPaneResizingPanel) - SaveLayout(xmlWriter, child as DocumentPaneResizingPanel); + //else if (child is DocumentPaneResizingPanel) + // SaveLayout(xmlWriter, child as DocumentPaneResizingPanel); else if (child is ResizingPanel) SaveLayout(xmlWriter, child as ResizingPanel); } @@ -2714,7 +3376,10 @@ namespace AvalonDock SaveLayout(stream); } - const string layoutFileVersion = "1.2.1"; + /// + /// Layout format version + /// + const string layoutFileVersion = "1.3.0"; /// /// Send layout configuration to a object @@ -2726,6 +3391,10 @@ namespace AvalonDock if (!_isControlLoaded) throw new InvalidOperationException("Unable to serialize docking layout while DockingManager control is unloaded"); + EnsureContentNotEmpty(); + ClearEmptyPanes(); + HideFlyoutWindow(); + sw.WriteStartElement("DockingManager"); sw.WriteAttributeString("version", layoutFileVersion); @@ -2733,18 +3402,20 @@ namespace AvalonDock SaveLayout(sw, Content as ResizingPanel); else if (Content is DocumentPane) SaveLayout(sw, Content as DocumentPane); - else if (Content is DocumentPaneResizingPanel) - SaveLayout(sw, Content as DocumentPaneResizingPanel); + //else if (Content is DocumentPaneResizingPanel) + // SaveLayout(sw, Content as DocumentPaneResizingPanel); sw.WriteStartElement("Hidden"); - foreach (DockableContent content in _hiddenContents) + + var hiddenContents = DockableContents.Where(c => c.State == DockableContentState.Hidden).ToArray(); + foreach (DockableContent content in hiddenContents) { SaveLayout(sw, content); } sw.WriteEndElement(); sw.WriteStartElement("Windows"); - foreach (DockableFloatingWindow flWindow in _floatingWindows) + foreach (var flWindow in _floatingWindows.OfType()) { SaveLayout(sw, flWindow); } @@ -2763,7 +3434,7 @@ namespace AvalonDock DockablePane parentContainer = content.Parent as DockablePane; if (parentContainer != null && parentContainer.Items.Count == 1) - ToggleAutoHide(content.Parent as DockablePane); + parentContainer.ToggleAutoHide(); } if (content.State == DockableContentState.DockableWindow || content.State == DockableContentState.FloatingWindow) @@ -2779,7 +3450,7 @@ namespace AvalonDock } //this content can be hidden also if was contained in closed floating window if (content.State == DockableContentState.Hidden) - Show(content); + Show(content, DockableContentState.Docked); content.DetachFromContainerPane(); } @@ -2789,64 +3460,165 @@ namespace AvalonDock public DeserializationCallbackHandler DeserializationCallback { get; set; } - void ShowAllHiddenContents() + //void ShowAllHiddenContents() + //{ + // var hiddenContents = DockableContents.Where(c => c.State == DockableContentState.Hidden).ToArray(); + // foreach (var hiddenContent in hiddenContents) + // { + // //Debug.Assert(HiddenContents[0].State == DockableContentState.Hidden); + // hiddenContent.Show(); + // } + //} + + #region Restore Layout Overloads + + /// + /// Restore a layout from xml + /// + /// + public void RestoreLayout(Stream backendStream) { - while (_hiddenContents.Count > 0) - { - Debug.Assert(_hiddenContents[0].State == DockableContentState.Hidden); - Show(_hiddenContents[0]); - } + XmlDocument doc = new XmlDocument(); + + doc.Load(backendStream); + + RestoreLayout(doc); } - void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents) + /// + /// Restore a layout from xml + /// + /// + public void RestoreLayout(XmlReader reader) { - mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel); - if (mainExistingDocumentPane != null) - { - existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel(); - } - else - { - existingDocumentPanel = null; - } + XmlDocument doc = new XmlDocument(); + + doc.Load(reader); - if (existingDocumentPanel != null) - { - if (existingDocumentPanel.Parent is ResizingPanel) - { - ((ResizingPanel)existingDocumentPanel.Parent).RemoveChild(existingDocumentPanel); - } - else if (existingDocumentPanel.Parent is DockingManager) - { - ((DockingManager)existingDocumentPanel.Parent).Content = null; - } - } - else if (mainExistingDocumentPane != null) - { - if (mainExistingDocumentPane.Parent is ResizingPanel) - { - ((ResizingPanel)mainExistingDocumentPane.Parent).RemoveChild(mainExistingDocumentPane); - } - else if (mainExistingDocumentPane.Parent is DockingManager) - { - ((DockingManager)mainExistingDocumentPane.Parent).Content = null; - } - } + RestoreLayout(doc); + } - foreach (XmlElement contentElement in childElement.ChildNodes) - { - if (contentElement.HasAttribute("Name")) + /// + /// Loads a xml content from a file and restore the layout contained in it + /// + /// + public void RestoreLayout(string filename) + { + XmlDocument doc = new XmlDocument(); + + doc.Load(filename); + + RestoreLayout(doc); + } + + /// + /// Restore a layout from a xml string + /// + /// + public void RestoreLayout(TextReader reader) + { + XmlDocument doc = new XmlDocument(); + + doc.Load(reader); + + RestoreLayout(doc); + } + + + #region Restore Layout Core + ///// + ///// Restore from xml a document pane + ///// + ///// + ///// + ///// + ///// + //void RestoreDocumentPaneLayout(XmlElement childElement, out DocumentPane mainExistingDocumentPane, out DocumentPaneResizingPanel existingDocumentPanel, DockableContent[] dockableContents) + //{ + // mainExistingDocumentPane = (Content is DocumentPane) ? Content as DocumentPane : GetMainDocumentPane(Content as ResizingPanel); + // if (mainExistingDocumentPane != null) + // { + // existingDocumentPanel = mainExistingDocumentPane.GetParentDocumentPaneResizingPanel(); + // } + // else + // { + // existingDocumentPanel = null; + // } + + // if (existingDocumentPanel != null) + // { + // if (existingDocumentPanel.Parent is ResizingPanel) + // { + // ((ResizingPanel)existingDocumentPanel.Parent).RemoveChild(existingDocumentPanel); + // } + // else if (existingDocumentPanel.Parent is DockingManager) + // { + // ((DockingManager)existingDocumentPanel.Parent).Content = null; + // } + // } + // else if (mainExistingDocumentPane != null) + // { + // if (mainExistingDocumentPane.Parent is ResizingPanel) + // { + // ((ResizingPanel)mainExistingDocumentPane.Parent).RemoveChild(mainExistingDocumentPane); + // } + // else if (mainExistingDocumentPane.Parent is DockingManager) + // { + // ((DockingManager)mainExistingDocumentPane.Parent).Content = null; + // } + // } + + // foreach (XmlElement contentElement in childElement.ChildNodes) + // { + // if (contentElement.HasAttribute("Name")) + // { + // DockableContent foundContent = null; + // string contentName = contentElement.GetAttribute("Name"); + // foreach (DockableContent content in dockableContents) + // { + // if (content.Name == contentName) + // { + // foundContent = content; + // break; + // } + // } + + // if (foundContent == null && + // DeserializationCallback != null) + // { + // DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); + // DeserializationCallback(this, e); + + // foundContent = e.Content as DockableContent; + // } + + + // if (foundContent != null) + // { + // DetachContentFromDockingManager(foundContent); + // mainExistingDocumentPane.Items.Add(foundContent); + // foundContent.SetStateToDocument(); + + // //call custom layout persistence method + // foundContent.RestoreLayout(contentElement); + // } + // } + // } + //} + + DocumentPane RestoreDocumentPaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments) + { + var documentPane = new DocumentPane(); + + foreach (XmlElement contentElement in mainElement.ChildNodes) + { + if (contentElement.Name == "DockableContent" && + contentElement.HasAttribute("Name")) { DockableContent foundContent = null; string contentName = contentElement.GetAttribute("Name"); - foreach (DockableContent content in dockableContents) - { - if (content.Name == contentName) - { - foundContent = content; - break; - } - } + + foundContent = actualContents.FirstOrDefault(c => c.Name == contentName); if (foundContent == null && DeserializationCallback != null) @@ -2854,176 +3626,215 @@ namespace AvalonDock DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); DeserializationCallback(this, e); - foundContent = e.Content; + foundContent = e.Content as DockableContent; } if (foundContent != null) { DetachContentFromDockingManager(foundContent); - mainExistingDocumentPane.Items.Add(foundContent); + documentPane.Items.Add(foundContent); foundContent.SetStateToDocument(); //call custom layout persistence method foundContent.RestoreLayout(contentElement); } } - } - } + else if (contentElement.Name == "DocumentContent" && + contentElement.HasAttribute("Name")) + { + DocumentContent foundDocument = null; + string contentName = contentElement.GetAttribute("Name"); - ResizingPanel RestoreLayout(XmlElement panelElement, DockableContent[] dockableContents) - { - ResizingPanel panel = new ResizingPanel(); + foundDocument = actualDocuments.FirstOrDefault(c => c.Name == contentName); - if (panelElement.HasAttribute("Orientation")) - panel.Orientation = (Orientation)Enum.Parse(typeof(Orientation), panelElement.GetAttribute("Orientation")); + if (foundDocument == null && + DeserializationCallback != null) + { + DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); + DeserializationCallback(this, e); + foundDocument = e.Content as DocumentContent; + } - foreach (XmlElement childElement in panelElement.ChildNodes) - { - if (childElement.Name == "ResizingPanel") - { - ResizingPanel childPanel = RestoreLayout(childElement, dockableContents); - if (childElement.HasAttribute("ResizeWidth")) - ResizingPanel.SetResizeWidth(childPanel, (GridLength)GLConverter.ConvertFromInvariantString(childElement.GetAttribute("ResizeWidth"))); - if (childElement.HasAttribute("ResizeHeight")) - ResizingPanel.SetResizeHeight(childPanel, (GridLength)GLConverter.ConvertFromInvariantString(childElement.GetAttribute("ResizeHeight"))); - if (childElement.HasAttribute("EffectiveSize")) - ResizingPanel.SetEffectiveSize(childPanel, (Size)(new SizeConverter()).ConvertFromInvariantString(childElement.GetAttribute("EffectiveSize"))); - - panel.Children.Add(childPanel); - } - #region Restore DockablePane - else if (childElement.Name == "DockablePane") - { - DockablePane pane = new DockablePane(); - if (childElement.HasAttribute("Anchor")) - pane.Anchor = (AnchorStyle)Enum.Parse(typeof(AnchorStyle), childElement.GetAttribute("Anchor")); - if (childElement.HasAttribute("ResizeWidth")) - ResizingPanel.SetResizeWidth(pane, (GridLength)GLConverter.ConvertFromInvariantString(childElement.GetAttribute("ResizeWidth"))); - if (childElement.HasAttribute("ResizeHeight")) - ResizingPanel.SetResizeHeight(pane, (GridLength)GLConverter.ConvertFromInvariantString(childElement.GetAttribute("ResizeHeight"))); - if (childElement.HasAttribute("EffectiveSize")) - ResizingPanel.SetEffectiveSize(pane, (Size)(new SizeConverter()).ConvertFromInvariantString(childElement.GetAttribute("EffectiveSize"))); + if (foundDocument != null) + { + foundDocument.DetachFromContainerPane(); + documentPane.Items.Add(foundDocument); + } + } + } - //storeWriter.WriteAttributeString( - // "EffectiveSize", new SizeConverter().ConvertToInvariantString(ResizingPanel.GetEffectiveSize(ContainerPane))); + return documentPane; - bool toggleAutoHide = false; - foreach (XmlElement contentElement in childElement.ChildNodes) - { - if (contentElement.HasAttribute("Name")) - { - DockableContent foundContent = null; - string contentName = contentElement.GetAttribute("Name"); - foreach (DockableContent content in dockableContents) - { - if (content.Name == contentName) - { - foundContent = content; - break; - } - } + } - if (foundContent == null && - DeserializationCallback != null) - { - DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); - DeserializationCallback(this, e); + DockablePane RestoreDockablePaneLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments) + { - foundContent = e.Content; - } + DockablePane pane = new DockablePane(); + if (mainElement.HasAttribute("Anchor")) + pane.Anchor = (AnchorStyle)Enum.Parse(typeof(AnchorStyle), mainElement.GetAttribute("Anchor")); + if (mainElement.HasAttribute("ResizeWidth")) + ResizingPanel.SetResizeWidth(pane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth"))); + if (mainElement.HasAttribute("ResizeHeight")) + ResizingPanel.SetResizeHeight(pane, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight"))); + if (mainElement.HasAttribute("EffectiveSize")) + ResizingPanel.SetEffectiveSize(pane, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize"))); + if (mainElement.HasAttribute("ID")) + pane.ID = Guid.Parse(mainElement.GetAttribute("ID")); - if (foundContent != null) - { - DetachContentFromDockingManager(foundContent); - pane.Items.Add(foundContent); - foundContent.SetStateToDock(); - if (contentElement.HasAttribute("AutoHide") && - XmlConvert.ToBoolean(contentElement.GetAttribute("AutoHide")) && - pane.Items.Count == 1) - toggleAutoHide = true; - - //call custom layout persistence method - foundContent.RestoreLayout(contentElement); - } - } - } - if (pane.Items.Count > 0) - { - if (toggleAutoHide) - ToggleAutoHide(pane); + bool toggleAutoHide = false; + if (mainElement.HasAttribute("IsAutoHidden")) + toggleAutoHide = XmlConvert.ToBoolean(mainElement.GetAttribute("IsAutoHidden")); - if (pane.Items.Count > 0) - panel.Children.Add(pane); - } - } - #endregion - #region Restore Contents inside a DocumentPane - else if (childElement.Name == "DocumentPanePlaceHolder") + foreach (XmlElement contentElement in mainElement.ChildNodes) + { + if (contentElement.HasAttribute("Name")) { - DocumentPaneResizingPanel existingDocumentPanel = null; - DocumentPane mainExistingDocumentPane = null; + DockableContent foundContent = null; + string contentName = contentElement.GetAttribute("Name"); - RestoreDocumentPaneLayout(childElement, out mainExistingDocumentPane, out existingDocumentPanel, dockableContents); + foundContent = actualContents.FirstOrDefault(c => c.Name == contentName); - if (existingDocumentPanel != null) + if (foundContent == null && + DeserializationCallback != null) { - panel.Children.Add(existingDocumentPanel); + DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentName); + DeserializationCallback(this, e); + + foundContent = e.Content as DockableContent; } - else if (mainExistingDocumentPane != null) + + + if (foundContent != null) { - panel.Children.Add(mainExistingDocumentPane); + DetachContentFromDockingManager(foundContent); + pane.Items.Add(foundContent); + foundContent.SetStateToDock(); + + //call custom layout persistence method + foundContent.RestoreLayout(contentElement); } } - - #endregion } - return panel; - } + if (toggleAutoHide && pane.Items.Count > 0) + ToggleAutoHide(pane); + return pane; + } - public void RestoreLayout(Stream backendStream) + ResizingPanel RestoreResizingPanel(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments, ref DocumentPane mainDocumentPane) { - XmlDocument doc = new XmlDocument(); + ResizingPanel panel = null; - doc.Load(backendStream); + if (mainElement.Name == "DocumentPaneResizingPanel") + panel = new DocumentPaneResizingPanel(); + else + panel = new ResizingPanel(); - RestoreLayout(doc); - } + if (mainElement.HasAttribute("Orientation")) + panel.Orientation = (Orientation)Enum.Parse(typeof(Orientation), mainElement.GetAttribute("Orientation")); + if (mainElement.HasAttribute("ResizeWidth")) + ResizingPanel.SetResizeWidth(panel, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeWidth"))); + if (mainElement.HasAttribute("ResizeHeight")) + ResizingPanel.SetResizeHeight(panel, (GridLength)GLConverter.ConvertFromInvariantString(mainElement.GetAttribute("ResizeHeight"))); + if (mainElement.HasAttribute("EffectiveSize")) + ResizingPanel.SetEffectiveSize(panel, (Size)(new SizeConverter()).ConvertFromInvariantString(mainElement.GetAttribute("EffectiveSize"))); - public void RestoreLayout(XmlReader reader) - { - XmlDocument doc = new XmlDocument(); - doc.Load(reader); + foreach (XmlElement childElement in mainElement.ChildNodes) + { + if (childElement.Name == "ResizingPanel" || + childElement.Name == "DocumentPaneResizingPanel") + { + var childPanel = RestoreResizingPanel(childElement, actualContents, actualDocuments, ref mainDocumentPane); - RestoreLayout(doc); - } + if (childPanel.Children.Count > 0) + { + panel.Children.Add(childPanel); + } + else + { + Debug.WriteLine("Found empty ResizingPanel in stored layout, it will be discarded."); + } + } + #region Restore DockablePane + else if (childElement.Name == "DockablePane") + { + var pane = RestoreDockablePaneLayout(childElement, actualContents, actualDocuments); - public void RestoreLayout(string filename) - { - XmlDocument doc = new XmlDocument(); + //restore dockable panes even if no contents are inside (an hidden content could refer this pane in SaveStateAndPosition) + panel.Children.Add(pane); - doc.Load(filename); + } + #endregion + #region Restore Contents inside a DocumentPane + else if (childElement.Name == "DocumentPane") + { + var documentPane = RestoreDocumentPaneLayout(childElement, actualContents, actualDocuments); + + bool isMainDocumentPane = false; + if (childElement.HasAttribute("IsMain")) + isMainDocumentPane = XmlConvert.ToBoolean(childElement.GetAttribute("IsMain")); - RestoreLayout(doc); + if (documentPane.Items.Count > 0 || + isMainDocumentPane) + panel.Children.Add(documentPane); + + if (isMainDocumentPane) + { + if (mainDocumentPane != null) + throw new InvalidOperationException("Main document pane is set more than one time"); + + mainDocumentPane = documentPane; + } + } + + #endregion + } + + return panel; + } - public void RestoreLayout(TextReader reader) + /// + /// Restore from xml a resizing panel or a documentpane + /// + /// + /// + /// + object RestoreLayout(XmlElement mainElement, DockableContent[] actualContents, DocumentContent[] actualDocuments, ref DocumentPane mainDocumentPane) { - XmlDocument doc = new XmlDocument(); + if (mainElement == null) + throw new ArgumentNullException("mainElement"); - doc.Load(reader); + if (mainElement.Name == "ResizingPanel" || + mainElement.Name == "DocumentPaneResizingPanel") + { + return RestoreResizingPanel(mainElement, actualContents, actualDocuments, ref mainDocumentPane); + } + else if (mainElement.Name == "DocumentPane") + { + mainDocumentPane = RestoreDocumentPaneLayout(mainElement, actualContents, actualDocuments); + return mainDocumentPane; + } - RestoreLayout(doc); + throw new InvalidOperationException(string.Format("Unable to deserialize '{0}' element", mainElement.Name)); } - + /// + /// True while is restoring a layout + /// + protected bool RestoringLayout { get; private set; } + /// + /// Internal main restore layout method + /// + /// Document Xml from which restore layout void RestoreLayout(XmlDocument doc) { if (!_isControlLoaded) @@ -3035,12 +3846,12 @@ namespace AvalonDock Debug.Assert(false, "Layout file hasn't a valid structure!"); throw new InvalidOperationException("Layout file had not a valid structure!"); } - + if (doc.DocumentElement.GetAttribute("version") != layoutFileVersion) throw new FileFormatException("Unsupported layout file version"); if (doc.DocumentElement.ChildNodes.Count != 3 || - (doc.DocumentElement.ChildNodes[0].Name != "ResizingPanel" && doc.DocumentElement.ChildNodes[0].Name != "DocumentPanePlaceHolder") || + (doc.DocumentElement.ChildNodes[0].Name != "ResizingPanel" && doc.DocumentElement.ChildNodes[0].Name != "DocumentPane") || doc.DocumentElement.ChildNodes[1].Name != "Hidden" || doc.DocumentElement.ChildNodes[2].Name != "Windows") { @@ -3049,50 +3860,44 @@ namespace AvalonDock } //Hide temp windows - HideAutoHideWindow(); + HideFlyoutWindow(); HideNavigatorWindow(); - HideDocumentNavigatorWindow(); + //HideDocumentNavigatorWindow(); - DockableContent[] actualContents = DockableContents; - + RestoringLayout = true; - //show all hidden contents - ShowAllHiddenContents(); + //show all auto hidden panes + var panesAutoHidden = DockableContents.Where(c => c.State == DockableContentState.AutoHide).Select(c => c.ContainerPane).Distinct(); + foreach (DockablePane pane in panesAutoHidden) + pane.ToggleAutoHide(); - //restore main panel - XmlElement rootElement = doc.DocumentElement.ChildNodes[0] as XmlElement; - if (rootElement.Name == "ResizingPanel") - { - this.Content = RestoreLayout(rootElement, actualContents); - } - else if (rootElement.Name == "DocumentPanePlaceHolder") - { - DocumentPaneResizingPanel existingDocumentPanel = null; - DocumentPane mainExistingDocumentPane = null; + DockableContent[] actualContents = DockableContents.ToArray(); + DocumentContent[] actualDocuments = Documents.ToArray(); - RestoreDocumentPaneLayout(rootElement, out mainExistingDocumentPane, out existingDocumentPanel, actualContents); - if (existingDocumentPanel != null) - { - this.Content = existingDocumentPanel; - } - else if (mainExistingDocumentPane != null) - { - this.Content = mainExistingDocumentPane; - } - } + //first detach all my actual contents + this.Content = null; + this.ActiveContent = null; + this.ActiveDocument = null; + //restore main panel + XmlElement rootElement = doc.DocumentElement.ChildNodes[0] as XmlElement; + DocumentPane mainDocumentPane = null; + this.Content = RestoreLayout(rootElement, actualContents, actualDocuments, ref mainDocumentPane); + MainDocumentPane = mainDocumentPane; + //restore hidden contents foreach (XmlElement hiddenContentElement in doc.DocumentElement.ChildNodes[1].ChildNodes) { - foreach (DockableContent hiddenContent in actualContents) + var hiddenContentName = hiddenContentElement.GetAttribute("Name"); + + var hiddenContent = actualContents.FirstOrDefault(c => c.Name == hiddenContentName && + c.State != DockableContentState.Hidden); + + if (hiddenContent != null) { - if (hiddenContentElement.GetAttribute("Name") == hiddenContent.Name - && hiddenContent.State != DockableContentState.Hidden) - { - Hide(hiddenContent); - hiddenContent.RestoreLayout(hiddenContentElement); - } + Hide(hiddenContent); + hiddenContent.RestoreLayout(hiddenContentElement); } } @@ -3106,16 +3911,9 @@ namespace AvalonDock Point location = new Point(XmlConvert.ToDouble(flWindowElement.GetAttribute("Left")), XmlConvert.ToDouble(flWindowElement.GetAttribute("Top"))); Size size = new Size(XmlConvert.ToDouble(flWindowElement.GetAttribute("Width")), XmlConvert.ToDouble(flWindowElement.GetAttribute("Height"))); - DockableFloatingWindow flWindow = new DockableFloatingWindow(this); - flWindow.Left = location.X; - flWindow.Top = location.Y; - flWindow.Width = size.Width; - flWindow.Height = size.Height; - flWindow.Owner = Window.GetWindow(this); - XmlElement paneElement = flWindowElement.ChildNodes[0] as XmlElement; - FloatingDockablePane paneForFloatingWindow = new FloatingDockablePane(flWindow); + DockablePane paneForFloatingWindow = new DockablePane(); if (paneElement.HasAttribute("ResizingWidth")) ResizingPanel.SetResizeWidth(paneForFloatingWindow, (GridLength)GLConverter.ConvertFromInvariantString(paneElement.GetAttribute("ResizeWidth"))); if (paneElement.HasAttribute("ResizingHeight")) @@ -3127,15 +3925,8 @@ namespace AvalonDock foreach (XmlElement contentElement in paneElement.ChildNodes) { #region Find the content to transfer - string contentToFindName = contentElement.GetAttribute("Name"); - foreach (DockableContent content in actualContents) - { - if (contentToFindName == content.Name) - { - contentToTransfer = content; - break; - } - } + string contentToFindName = contentElement.GetAttribute("Name"); + contentToTransfer = actualContents.FirstOrDefault(c => c.Name == contentToFindName); if (contentToTransfer == null && DeserializationCallback != null) @@ -3143,11 +3934,9 @@ namespace AvalonDock DeserializationCallbackEventArgs e = new DeserializationCallbackEventArgs(contentToFindName); DeserializationCallback(this, e); - contentToTransfer = e.Content; + contentToTransfer = e.Content as DockableContent; } #endregion - - if (contentToTransfer != null) { DetachContentFromDockingManager(contentToTransfer); @@ -3156,17 +3945,64 @@ namespace AvalonDock } } - flWindow.HostedPane = paneForFloatingWindow; - flWindow.IsDockableWindow = isDockableWindow; + if (paneForFloatingWindow.Items.Count > 0) + { + var flWindow = new DockableFloatingWindow(this); + flWindow.Content = paneForFloatingWindow; + flWindow.Left = location.X; + flWindow.Top = location.Y; + flWindow.Width = size.Width; + flWindow.Height = size.Height; + flWindow.Owner = Window.GetWindow(this); + + flWindow.IsDockableWindow = isDockableWindow; + flWindow.ShowActivated = false; - RegisterFloatingWindow(flWindow); + flWindow.ApplyTemplate(); + flWindow.Show(); + } + } - flWindow.ApplyTemplate(); - flWindow.Show(); + ClearEmptyPanels(Content as ResizingPanel); + //get documents that are not present in last layout and must be included + //in the new one + var documentsNotTransferred = actualDocuments.Where(d => d.ContainerPane == null || d.ContainerPane.GetManager() != this).ToArray(); + + Debug.Assert(MainDocumentPane != null && MainDocumentPane.GetManager() == this); + + if (MainDocumentPane != null && documentsNotTransferred.Count() > 0) + { + documentsNotTransferred.ForEach(d => MainDocumentPane.Items.Add(d.DetachFromContainerPane())); } - } + //get contents that are not present in the new layout and hide them + var contentsNotTransferred = actualContents.Where(c => c.ContainerPane == null || c.ContainerPane.GetManager() != this).ToArray(); + + contentsNotTransferred.ForEach(c => + { + Hide(c); + }); + + RestoringLayout = false; + + ClearEmptyPanes(); + RefreshContents(); + + if (Documents.Count() > 0) + { + ActiveContent = Documents[0]; + } + else + { + ActiveContent = null; + ActiveDocument = null; + } + + } + #endregion + + #endregion /// /// Static converter used to convert GridLength from/to string /// @@ -3174,9 +4010,7 @@ namespace AvalonDock #endregion - #region OnClosing/OnClosedDocument events - /// /// Event fired when the document is about to be closed /// @@ -3218,26 +4052,24 @@ namespace AvalonDock OnDocumentClosed(); } + //public event EventHandler RequestDocumentClose; - public event EventHandler RequestDocumentClose; - - internal bool FireRequestDocumentCloseEvent(DocumentContent doc) - { - bool res = false; + //internal bool FireRequestDocumentCloseEvent(DocumentContent doc) + //{ + // bool res = false; - if (RequestDocumentClose != null) - { - RequestDocumentCloseEventArgs args = new RequestDocumentCloseEventArgs(doc); - RequestDocumentClose(this, args); - res = !args.Cancel; - } + // if (RequestDocumentClose != null) + // { + // RequestDocumentCloseEventArgs args = new RequestDocumentCloseEventArgs(doc); + // RequestDocumentClose(this, args); + // res = !args.Cancel; + // } - return res; - } + // return res; + //} #endregion - } } diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs new file mode 100644 index 0000000000..1271e6232a --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentContent.cs @@ -0,0 +1,442 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Diagnostics; + + +namespace AvalonDock +{ + /// + /// Represent a document which can be host by a . + /// + /// A document is always hosted by a usually in the central area of . + /// It has limited dragging features becaus it can be only moved to an other and can't float as a separate window. + /// You can access all documents within with property . + public class DocumentContent : ManagedContent + { + + static DocumentContent() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(DocumentContent), new FrameworkPropertyMetadata(typeof(DocumentContent))); + + //Control.WidthProperty.OverrideMetadata(typeof(DocumentContent), + // new FrameworkPropertyMetadata(new PropertyChangedCallback(OnSizePropertyChanged), new CoerceValueCallback(CourceSizeToNaN))); + //Control.HeightProperty.OverrideMetadata(typeof(DocumentContent), + // new FrameworkPropertyMetadata(new PropertyChangedCallback(OnSizePropertyChanged), new CoerceValueCallback(CourceSizeToNaN))); + } + + public DocumentContent() + { + //base.PropertyChanged += new PropertyChangedEventHandler(DocumentContent_PropertyChanged); + } + + protected override void OnContentLoaded() + { + //now the logical tree is up + DockingManager manager = GetParentManager(null); + + //if can't find the manager there is a problem + //if (manager == null) + // throw new InvalidOperationException(string.Format( + // "Unable to find DockingManager object in the logical tree of document '{0}'", Title)); + + //manager.Documents.Add(this); + + base.OnContentLoaded(); + } + + protected override void OnContentUnloaded() + { + //if (Manager != null) + // Manager.Documents.Remove(this); + + base.OnContentUnloaded(); + } + + #region InfoTip + + /// + /// InfoTip Dependency Property + /// + public static readonly DependencyProperty InfoTipProperty = + DependencyProperty.Register("InfoTip", typeof(string), typeof(DocumentContent), + new FrameworkPropertyMetadata(null)); + + /// + /// Gets or sets the InfoTip property. This dependency property + /// indicates information text attached to the document content. + /// + /// This text is usually displayed when users switch between documents and helps them to choose the right one. + public string InfoTip + { + get { return (string)GetValue(InfoTipProperty); } + set { SetValue(InfoTipProperty, value); } + } + + #endregion + + #region ContentTypeDescription + + /// + /// ContentTypeDescription Dependency Property + /// + public static readonly DependencyProperty ContentTypeDescriptionProperty = + DependencyProperty.Register("ContentTypeDescription", typeof(string), typeof(DocumentContent), + new FrameworkPropertyMetadata((string)string.Empty)); + + /// + /// Gets or sets the ContentTypeDescription property. This dependency property + /// indicates a text which describes the type of content contained in this document. + /// + public string ContentTypeDescription + { + get { return (string)GetValue(ContentTypeDescriptionProperty); } + set { SetValue(ContentTypeDescriptionProperty, value); } + } + + #endregion + + /// + /// Gets or sets a value indicating if this document can float over main window (VS2010 Feature). + /// + public bool IsFloatingAllowed + { + get { return (bool)GetValue(IsFloatingAllowedProperty); } + set { SetValue(IsFloatingAllowedProperty, value); } + } + + // Using a DependencyProperty as the backing store for IsFloatingAllowed. This enables animation, styling, binding, etc... + public static readonly DependencyProperty IsFloatingAllowedProperty = + DependencyProperty.Register("IsFloatingAllowed", typeof(bool), typeof(DocumentContent), new PropertyMetadata(true)); + + + #region IsFloating + + /// + /// IsFloating Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey IsFloatingPropertyKey + = DependencyProperty.RegisterReadOnly("IsFloating", typeof(bool), typeof(DocumentContent), + new FrameworkPropertyMetadata((bool)false)); + + public static readonly DependencyProperty IsFloatingProperty + = IsFloatingPropertyKey.DependencyProperty; + + /// + /// Gets the IsFloating property. This dependency property + /// indicates if the DocumentContent is floating inside an external window. + /// + public bool IsFloating + { + get { return (bool)GetValue(IsFloatingProperty); } + } + + /// + /// Provides a secure method for setting the IsFloating property. + /// This dependency property indicates if the DocumentContent is floating inside an external window. + /// + /// The new value for the property. + internal void SetIsFloating(bool value) + { + SetValue(IsFloatingPropertyKey, value); + } + + #endregion + + + protected override void OnDragStart(Point ptMouse, Point ptRelativeMouse) + { + if (IsFloatingAllowed) + { + Manager.Drag(this, HelperFunc.PointToScreenWithoutFlowDirection(this, ptMouse), ptRelativeMouse); + } + + base.OnDragStart(ptMouse, ptRelativeMouse); + } + + protected override void OnDragMouseMove(object sender, MouseEventArgs e) + { + base.OnDragMouseMove(sender, e); + } + + protected override void OnDragMouseLeave(object sender, MouseEventArgs e) + { + + base.OnDragMouseLeave(sender, e); + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (DragEnabledArea != null) + { + if (string.IsNullOrEmpty((string)DragEnabledArea.ToolTip)) + DragEnabledArea.ToolTip = InfoTip; + } + } + + protected override void OnInitialized(EventArgs e) + { + base.OnInitialized(e); + + this.CommandBindings.Add( + new CommandBinding(DocumentContentCommands.FloatingDocument, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DocumentContentCommands.TabbedDocument, this.OnExecuteCommand, this.OnCanExecuteCommand)); + } + + void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + { + if (!e.Handled && e.Command == DocumentContentCommands.FloatingDocument) + { + this.Show(true); + + e.Handled = true; + } + else if (!e.Handled && e.Command == DocumentContentCommands.TabbedDocument) + { + this.Show(false); + + e.Handled = true; + } + } + + void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = CanExecuteCommand(e.Command); + } + + /// + /// Show as tabbed document + /// + public override void Show() + { + Show(false); + } + + /// + /// Show as tabbed document inside the provided + /// + /// Docking manager target + public override void Show(DockingManager manager) + { + Show(manager, false); + } + + /// + /// Show as tabbed document or inside a floating window + /// + public void Show(bool showAsFloatingWindow) + { + if (!CanExecuteCommand(ManagedContentCommands.Show)) + throw new InvalidOperationException("This operation can be executed in this state"); + + Manager.Show(this, showAsFloatingWindow); + } + + /// + /// Show as tabbed document inside the provided + /// + /// Docking manager target + /// True if document should be shown inside a floating window () + public void Show(DockingManager manager, bool showAsFloatingWindow) + { + if (Manager != null && Manager != manager) + throw new InvalidOperationException("Please remove the content from previous DockingManager (using the Close method)"); + + if (!CanExecuteCommand(ManagedContentCommands.Show)) + throw new InvalidOperationException("This operation can be executed in this state"); + + manager.Show(this, showAsFloatingWindow); + + manager.Documents.Add(this); + } + + /// + /// Activate the document showing its header if it's not visible + /// + public override void Activate() + { + base.Activate(); + + if (!DocumentTabPanel.GetIsHeaderVisible(this)) + { + DocumentPane parentPane = this.ContainerPane as DocumentPane; + if (parentPane != null && + parentPane.GetManager() != null && + parentPane.Items.IndexOf(this) != 0) + { + parentPane.Items.Remove(this); + parentPane.Items.Insert(0, this); + parentPane.SelectedIndex = 0; + } + } + } + + /// + /// Retrive a value indicating if the command can be executed based to the dockable content state + /// + /// + /// + protected override bool CanExecuteCommand(ICommand command) + { + if (command == DocumentContentCommands.FloatingDocument) + { + return !IsFloating && IsFloatingAllowed; + } + else if (command == DocumentContentCommands.TabbedDocument) + { + return IsFloating; + } + + return true; + } + + /// + /// Close this content without notifications + /// + internal void InternalClose() + { + DockingManager manager = Manager; + + if (manager != null) + { + if (manager.ActiveContent == this) + manager.ActiveContent = null; + + if (manager.ActiveDocument == this) + manager.ActiveDocument = null; + } + + DocumentPane parentPane = ContainerPane as DocumentPane; + FloatingDocumentPane floatingParentPane = ContainerPane as FloatingDocumentPane; + + if (floatingParentPane != null) + { + floatingParentPane.RemoveContent(0); + if (floatingParentPane.FloatingWindow != null && + !floatingParentPane.FloatingWindow.IsClosing) + floatingParentPane.FloatingWindow.Close(); + } + else if (parentPane != null) + { + parentPane.Items.Remove(this); + + parentPane.CheckContentsEmpty(); + } + } + + /// + /// Close this document removing it from its parent container + /// + /// Use this function to close a document and remove it from its parent container. Please note + /// that if you simply remove it from its parent without call this method, events like + /// / are not called. + /// + public override bool Close() + { + if (!IsCloseable) + return false; + + ////if documents are attached to an external source via DockingManager.DocumentsSource + ////let application host handle the document closing by itself + //if (Manager.DocumentsSource != null) + //{ + // //return Manager.FireRequestDocumentCloseEvent(this); + // Manager.HandleDocumentClose(this); + //} + + + CancelEventArgs e = new CancelEventArgs(false); + OnClosing(e); + + if (e.Cancel) + return false; + + DockingManager oldManager = Manager; + + if (Manager != null) + Manager.FireDocumentClosingEvent(e); + + if (e.Cancel) + return false; + + InternalClose(); + + OnClosed(); + + //if documents are attached to an external source via DockingManager.DocumentsSource + //let application host handle the document closing by itself + if (Manager != null && Manager.DocumentsSource != null) + { + Manager.HandleDocumentClose(this); + } + + if (oldManager != null) + oldManager.FireDocumentClosedEvent(); + + + Debug.Assert(Parent == null, "Parent MUST bu null after Doc is closed"); + return true; + } + + /// + /// Hide the (Close the document) + /// + /// + public override bool Hide() + { + return Close(); + } + + + + #region Save/RestoreLayout + public override void SaveLayout(System.Xml.XmlWriter storeWriter) + { + base.SaveLayout(storeWriter); + } + + public override void RestoreLayout(System.Xml.XmlElement contentElement) + { + base.RestoreLayout(contentElement); + } + #endregion + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentContentCommands.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentContentCommands.cs new file mode 100644 index 0000000000..17c76e67ea --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentContentCommands.cs @@ -0,0 +1,83 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + /// + /// Contains a list of commands that can be applied to a + /// + public sealed class DocumentContentCommands + { + static object syncRoot = new object(); + + private static RoutedUICommand _floatingDocumentCommand = null; + + /// + /// Shows the as a floating window document + /// + public static RoutedUICommand FloatingDocument + { + get + { + lock (syncRoot) + { + if (null == _floatingDocumentCommand) + { + _floatingDocumentCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DocumentContentCommands_FloatingDocument, "FloatingDocument", typeof(DocumentContentCommands)); + } + } + return _floatingDocumentCommand; + } + } + + + private static RoutedUICommand _tabbedDocumentCommand = null; + + /// + /// Shows the as a tabbed document + /// + public static RoutedUICommand TabbedDocument + { + get + { + lock (syncRoot) + { + if (null == _tabbedDocumentCommand) + { + _tabbedDocumentCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DocumentContentCommands_TabbedDocument, "TabbedDocument", typeof(DocumentContentCommands)); + } + } + return _tabbedDocumentCommand; + } + } + + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs new file mode 100644 index 0000000000..8ec877bf3b --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentFloatingWindow.cs @@ -0,0 +1,295 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Markup; +using System.Diagnostics; +using System.Windows.Threading; +using System.Windows.Media.Animation; +using System.Windows.Interop; +using System.Linq; + +namespace AvalonDock +{ + public class DocumentFloatingWindow : FloatingWindow + { + static DocumentFloatingWindow() + { + //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. + //This style is defined in themes\generic.xaml + DefaultStyleKeyProperty.OverrideMetadata(typeof(DocumentFloatingWindow), new FrameworkPropertyMetadata(typeof(DocumentFloatingWindow))); + + ContentProperty.OverrideMetadata(typeof(DocumentFloatingWindow), + new FrameworkPropertyMetadata( + new PropertyChangedCallback(OnContentPropertyChanged), + new CoerceValueCallback(OnCoerceValueContentProperty))); + } + + //DocumentPane _previousPane = null; + + //int _arrayIndexPreviousPane = -1; + + internal DocumentFloatingWindow(DockingManager manager) + :base(manager) + { + } + + //public DocumentFloatingWindow(DockingManager manager, DocumentContent content) + // : this(manager) + //{ + // //create a new temporary pane + // FloatingDocumentPane pane = new FloatingDocumentPane(this); + + // //setup window size + // Width = content.ContainerPane.ActualWidth; + // Height = content.ContainerPane.ActualHeight; + + // //save current content position in container pane + // _previousPane = content.ContainerPane as DocumentPane; + // _arrayIndexPreviousPane = _previousPane.Items.IndexOf(content); + // pane.SetValue(ResizingPanel.ResizeWidthProperty, _previousPane.GetValue(ResizingPanel.ResizeWidthProperty)); + // pane.SetValue(ResizingPanel.ResizeHeightProperty, _previousPane.GetValue(ResizingPanel.ResizeHeightProperty)); + + // pane.Style = _previousPane.Style; + + // //remove content from container pane + // _previousPane.RemoveContent(_arrayIndexPreviousPane); + + // //add content to my temporary pane + // pane.Items.Add(content); + + // //let templates access this pane + // SetHostedPane(pane); + + // //if (IsDocumentFloatingAllowed) + // //{ + // // AllowsTransparency = false; + // // WindowStyle = WindowStyle.ToolWindow; + // //} + //} + + //public bool IsDocumentFloatingAllowed + //{ + // get + // { + // if (HostedPane != null && + // HostedPane.Items.Count > 0) + // return ((DocumentContent)HostedPane.Items[0]).IsFloatingAllowed; + + // return false; + // } + //} + + + internal override void OnEndDrag() + { + //if (HostedPane.Items.Count > 0) + //{ + // DocumentContent content = HostedPane.Items[0] as DocumentContent; + // if (!content.IsFloatingAllowed) + // { + // HostedPane.Items.RemoveAt(0); + // _previousPane.Items.Insert(_arrayIndexPreviousPane, content); + // _previousPane.SelectedItem = content; + // Close(); + // } + // else + // { + // DocumentPane originalDocumentPane = _previousPane as DocumentPane; + // originalDocumentPane.CheckContentsEmpty(); + // } + //} + //else + //{ + // DocumentPane originalDocumentPane = _previousPane as DocumentPane; + // originalDocumentPane.CheckContentsEmpty(); + // Close(); + //} + + ((FloatingDocumentPane)HostedPane).PreviousPane.CheckContentsEmpty(); + + if (HostedPane.Items.Count == 0) + Close(); + + base.OnEndDrag(); + } + + public override Pane ClonePane() + { + DocumentPane paneToAnchor = new DocumentPane(); + + ResizingPanel.SetEffectiveSize(paneToAnchor, new Size(Width, Height)); + + //transfer contents from hosted pane in the floating window and + //the new created dockable pane + while (HostedPane.Items.Count > 0) + { + paneToAnchor.Items.Add( + HostedPane.RemoveContent(0)); + } + paneToAnchor.ApplyTemplate(); + + return paneToAnchor; + } + + internal override void OnShowSelectionBox() + { + this.Visibility = Visibility.Hidden; + base.OnShowSelectionBox(); + } + + internal override void OnHideSelectionBox() + { + this.Visibility = Visibility.Visible; + base.OnHideSelectionBox(); + } + + public override void Dock() + { + //if (_previousPane != null) + //{ + // if (_previousPane.GetManager() == null) + // { + // Manager.MainDocumentPane.Items.Insert(0, HostedPane.RemoveContent(0)); + // } + // else + // { + // if (_arrayIndexPreviousPane > _previousPane.Items.Count) + // _arrayIndexPreviousPane = _previousPane.Items.Count; + + // _previousPane.Items.Insert(_arrayIndexPreviousPane, HostedPane.RemoveContent(0)); + // _previousPane.SelectedIndex = _arrayIndexPreviousPane; + // } + // this.Close(); + //} + + ((DocumentContent)HostedPane.Items[0]).Show(); + + base.Dock(); + } + + protected override void FilterMessage(object sender, FilterMessageEventArgs e) + { + e.Handled = false; + + if (Manager == null) + return; + + switch (e.Msg) + { + case WM_NCLBUTTONDOWN: //Left button down on title -> start dragging over docking manager + if (e.WParam.ToInt32() == HTCAPTION) + { + short x = (short)((e.LParam.ToInt32() & 0xFFFF)); + short y = (short)((e.LParam.ToInt32() >> 16)); + + Point clickPoint = this.TransformToDeviceDPI(new Point(x, y)); + Manager.Drag(this, clickPoint, new Point(clickPoint.X - Left, clickPoint.Y - Top)); + + e.Handled = true; + } + break; + case WM_NCLBUTTONDBLCLK: //Left Button Double Click -> Maximixe/Normal + if (e.WParam.ToInt32() == HTCAPTION) + { + WindowState = WindowState == System.Windows.WindowState.Maximized ? + System.Windows.WindowState.Normal : System.Windows.WindowState.Maximized; + e.Handled = true; + } + break; + } + + + + base.FilterMessage(sender, e); + } + + protected override bool OpenContextMenu(UIElement popupButton, Point ptMouse) + { + ContextMenu cxMenu = FindResource(new ComponentResourceKey(typeof(DockingManager), + ContextMenuElement.DocumentFloatingWindow)) as ContextMenu; + if (cxMenu != null) + { + foreach (var menuItem in cxMenu.Items.OfType()) + menuItem.CommandTarget = HostedPane.SelectedItem as IInputElement; + + if (popupButton != null) + { + cxMenu.Placement = PlacementMode.Bottom; + cxMenu.PlacementTarget = popupButton; + } + else + { + cxMenu.Placement = PlacementMode.Bottom; + cxMenu.PlacementRectangle = new Rect(ptMouse, new Size(0, 0)); + } + + cxMenu.IsOpen = true; + return true; + } + + return base.OpenContextMenu(popupButton, ptMouse); + } + + static void OnContentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + + } + + static object OnCoerceValueContentProperty(DependencyObject d, object baseValue) + { + DocumentFloatingWindow fl = ((DocumentFloatingWindow)d); + + if (fl.Content != null) + { + throw new InvalidOperationException("Content on floating windows can't be set more than one time."); + } + + if (!(baseValue is DocumentContent)) + { + throw new InvalidOperationException("Content must be of type DocumentContent"); + } + + FloatingDocumentPane paneToReturn = null; + + if (baseValue is DocumentContent) + paneToReturn = new FloatingDocumentPane(fl, baseValue as DocumentContent); + + return paneToReturn; + } + } +} diff --git a/src/Libraries/AvalonDock/DocumentNavigator.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentNavigatorWindow.cs similarity index 86% rename from src/Libraries/AvalonDock/DocumentNavigator.cs rename to src/Libraries/AvalonDock/AvalonDock/DocumentNavigatorWindow.cs index 5150241baf..597366935b 100644 --- a/src/Libraries/AvalonDock/DocumentNavigator.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentNavigatorWindow.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -37,20 +37,22 @@ using System.Windows.Controls.Primitives; namespace AvalonDock { - public class DocumentNavigatorWindow : Window, INotifyPropertyChanged + public class DocumentNavigatorWindow : AvalonDockWindow, INotifyPropertyChanged { static DocumentNavigatorWindow() { - DefaultStyleKeyProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(typeof(DocumentNavigatorWindow))); + //DefaultStyleKeyProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(typeof(DocumentNavigatorWindow))); - Window.AllowsTransparencyProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(true)); - Window.WindowStyleProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(WindowStyle.None)); - Window.ShowInTaskbarProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(false)); - Control.BackgroundProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(Brushes.Transparent)); + AllowsTransparencyProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(true)); + WindowStyleProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(WindowStyle.None)); + ShowInTaskbarProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(false)); + BackgroundProperty.OverrideMetadata(typeof(DocumentNavigatorWindow), new FrameworkPropertyMetadata(Brushes.Transparent)); } - public DocumentNavigatorWindow() + public static object Theme; + + internal DocumentNavigatorWindow() { } @@ -96,9 +98,9 @@ namespace AvalonDock { base.OnActivated(e); - List listOfDocuments = _manager.FindContents(); + //List listOfDocuments = _manager.FindContents(); List docs = new List(); - listOfDocuments.ForEach((DocumentContent doc) => + _manager.Documents.ForEach((DocumentContent doc) => { docs.Add(new NavigatorWindowDocumentItem(doc)); }); @@ -134,13 +136,13 @@ namespace AvalonDock if (SelectedContent != null) { _manager.Show(SelectedContent.ItemContent as DocumentContent); - SelectedContent.ItemContent.SetAsActive(); + SelectedContent.ItemContent.Activate(); } } } if (!_isClosing) - CloseThisWindow();// Hide(); + CloseThisWindow(); base.OnDeactivated(e); } diff --git a/src/Libraries/AvalonDock/DocumentPane.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs similarity index 56% rename from src/Libraries/AvalonDock/DocumentPane.cs rename to src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs index 47379a056a..5d8ab68111 100644 --- a/src/Libraries/AvalonDock/DocumentPane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentPane.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -36,6 +36,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; using System.Diagnostics; +using System.Linq; namespace AvalonDock { @@ -46,6 +47,7 @@ namespace AvalonDock //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. //This style is defined in themes\generic.xaml DefaultStyleKeyProperty.OverrideMetadata(typeof(DocumentPane), new FrameworkPropertyMetadata(typeof(DocumentPane))); + } public DocumentPane() @@ -59,7 +61,8 @@ namespace AvalonDock return; if (GetManager() == null) - throw new InvalidOperationException("DocumentPane must be put under a DockingManager!"); + return; + //throw new InvalidOperationException("DocumentPane must be put under a DockingManager!"); //try to set this as main document pane if (GetManager().MainDocumentPane == null) @@ -74,6 +77,10 @@ namespace AvalonDock } } + /// + /// Returns a value indicating if this pane is the main document pane + /// + /// The main document pane is the default pane that remains always visible. public bool? IsMainDocumentPane { get @@ -85,223 +92,167 @@ namespace AvalonDock } } - protected override void OnInitialized(EventArgs e) - { - this.CommandBindings.Add( - new CommandBinding(ShowDocumentsListMenuCommand, ExecutedShowDocumentsListMenuCommand, CanExecuteShowDocumentsListMenuCommand)); - this.CommandBindings.Add( - new CommandBinding(ApplicationCommands.Close, ExecutedCloseCommand, CanExecuteCloseCommand)); - this.CommandBindings.Add( - new CommandBinding(CloseCommand, ExecutedCloseCommand, CanExecuteCloseCommand)); - this.CommandBindings.Add( - new CommandBinding(CloseAllButThisCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); - this.CommandBindings.Add( - new CommandBinding(NewHorizontalTabGroupCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); - this.CommandBindings.Add( - new CommandBinding(NewVerticalTabGroupCommand, this.OnExecuteCommand, this.OnCanExecuteCommand)); + #region ContainsActiveDocument - - base.OnInitialized(e); + internal void RefreshContainsActiveDocumentProperty() + { + SetContainsActiveDocument( + Items.Cast().FirstOrDefault(d => d.IsActiveDocument) != null); + + if (Items.Count > 0) + Debug.WriteLine("{0} ContainsActiveDocument ={1}", (Items[0] as ManagedContent).Title, ContainsActiveDocument); } - #region DocumentPane Commands - - - #region Show Document Window List Command - - public static RoutedCommand ShowDocumentsListMenuCommand = new RoutedCommand(); + + /// + /// ContainsActiveDocument Read-Only Dependency Property + /// + /// This property is especially intended for use in restyling. + private static readonly DependencyPropertyKey ContainsActiveDocumentPropertyKey + = DependencyProperty.RegisterReadOnly("ContainsActiveDocument", typeof(bool), typeof(DocumentPane), + new FrameworkPropertyMetadata((bool)false, + new PropertyChangedCallback(OnContainsActiveDocumentChanged))); + + public static readonly DependencyProperty ContainsActiveDocumentProperty + = ContainsActiveDocumentPropertyKey.DependencyProperty; + + /// + /// Gets the ContainsActiveDocument property. This dependency property + /// indicates if this pane contains a that has property set to true. + /// + public bool ContainsActiveDocument + { + get { return (bool)GetValue(ContainsActiveDocumentProperty); } + } - public void ExecutedShowDocumentsListMenuCommand(object sender, - ExecutedRoutedEventArgs e) + /// + /// Provides a secure method for setting the ContainsActiveDocument property. + /// This dependency property indicates if this pane contains a that has property set to true. + /// + /// The new value for the property. + protected void SetContainsActiveDocument(bool value) { - //MessageBox.Show("ShowOptionsMenu"); - ShowDocumentsListMenu(this, null); + SetValue(ContainsActiveDocumentPropertyKey, value); } + /// + /// Handles changes to the ContainsActiveDocument property. + /// + private static void OnContainsActiveDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((DocumentPane)d).OnContainsActiveDocumentChanged(e); + } - public void CanExecuteShowDocumentsListMenuCommand(object sender, - CanExecuteRoutedEventArgs e) + /// + /// Provides derived classes an opportunity to handle changes to the ContainsActiveDocument property. + /// + protected virtual void OnContainsActiveDocumentChanged(DependencyPropertyChangedEventArgs e) { - e.CanExecute = true; + NotifyPropertyChanged("ContainsActiveDocument"); } #endregion - - - #region Close Command - - //ApplicationCommands.Close command.... - - public void ExecutedCloseCommand(object sender, - ExecutedRoutedEventArgs e) + + protected override void OnInitialized(EventArgs e) { - if (GetManager() == null) - return; + this.CommandBindings.Add( + new CommandBinding(DocumentPaneCommands.CloseThis, OnExecuteCommand, OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DocumentPaneCommands.CloseAllButThis, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DocumentPaneCommands.NewHorizontalTabGroup, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(DocumentPaneCommands.NewVerticalTabGroup, this.OnExecuteCommand, this.OnCanExecuteCommand)); - ManagedContent contentToClose = SelectedItem as ManagedContent; - if (e.Parameter is ManagedContent) - contentToClose = e.Parameter as ManagedContent; + base.OnInitialized(e); + } - DockableContent dockableContent = contentToClose as DockableContent; + #region DocumentPane Commands - if (dockableContent != null) - CloseOrHide(dockableContent); - else - { - DocumentContent documentContent = contentToClose as DocumentContent; - documentContent.Close(); + //#region Show Document Window List Command - //if (documentContent != null) - // Items.Remove(documentContent); + //public static RoutedCommand ShowDocumentsListMenuCommand = new RoutedCommand(); - //CheckContentsEmpty(); - } + //public void ExecutedShowDocumentsListMenuCommand(object sender, + // ExecutedRoutedEventArgs e) + //{ + // //MessageBox.Show("ShowOptionsMenu"); + // ShowDocumentsListMenu(); + //} - } + //public void CanExecuteShowDocumentsListMenuCommand(object sender, + // CanExecuteRoutedEventArgs e) + //{ + // e.CanExecute = true; + //} - public void CanExecuteCloseCommand(object sender, - CanExecuteRoutedEventArgs e) - { - e.CanExecute = true; - } + //#endregion - #endregion + //#region Close Command - #region Activate Document Command - public static RoutedCommand ActivateDocumentCommand = new RoutedCommand(); + ////ApplicationCommands.Close command.... - public void ExecutedActivateDocumentCommand(object sender, - ExecutedRoutedEventArgs e) - { - ManagedContent doc = e.Parameter as ManagedContent; - if (doc != null) - { - if (!DocumentTabPanel.GetIsHeaderVisible(doc)) - { - DocumentPane parentPane = doc.ContainerPane as DocumentPane; - parentPane.Items.Remove(doc); - parentPane.Items.Insert(0, doc); - } - ////doc.IsSelected = true; - ////Selector.SetIsSelected(doc, true); - //if (this.GetManager() != null) - // this.GetManager().ActiveContent = doc; - doc.SetAsActive(); - } - } + //public void ExecutedCloseCommand(object sender, + // ExecutedRoutedEventArgs e) + //{ + //} - public void CanExecuteActivateDocumentCommand(object sender, - CanExecuteRoutedEventArgs e) - { - //ManagedContent doc = e.Parameter as ManagedContent; - //if (doc != null && !doc.IsSelected) - e.CanExecute = true; - } - #endregion + //public void CanExecuteCloseCommand(object sender, + // CanExecuteRoutedEventArgs e) + //{ + // e.CanExecute = true; + //} + //#endregion #region Commands - private static object syncRoot = new object(); - - private static RoutedUICommand closeAllButThisCommand = null; - public static RoutedUICommand CloseAllButThisCommand + protected override void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) { - get + if (e.Command == DocumentPaneCommands.CloseThis) { - lock (syncRoot) - { - if (null == closeAllButThisCommand) - { - closeAllButThisCommand = new RoutedUICommand("Close All But This", "CloseAllButThis", typeof(DocumentPane)); - } - } - return closeAllButThisCommand; - } - } - - private static RoutedUICommand closeCommand = null; - public static RoutedUICommand CloseCommand - { - get - { - lock (syncRoot) - { - if (null == closeCommand) - { - closeCommand = new RoutedUICommand("C_lose", "Close", typeof(DocumentPane)); - } - } - return closeCommand; - } - } - - private static RoutedUICommand newHTabGroupCommand = null; - public static RoutedUICommand NewHorizontalTabGroupCommand - { - get - { - lock (syncRoot) - { - if (null == newHTabGroupCommand) - { - newHTabGroupCommand = new RoutedUICommand("New Horizontal Tab Group", "NewHorizontalTabGroup", typeof(DocumentPane)); - } - } - return newHTabGroupCommand; - } - } - - private static RoutedUICommand newVTabGroupCommand = null; - public static RoutedUICommand NewVerticalTabGroupCommand - { - get - { - lock (syncRoot) - { - if (null == newVTabGroupCommand) - { - newVTabGroupCommand = new RoutedUICommand("New Vertical Tab Group", "NewVerticalTabGroup", typeof(DocumentPane)); - } - } - return newVTabGroupCommand; + CloseThis(e.Parameter as ManagedContent); + e.Handled = true; } - } - - - - internal virtual void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) - { - if (e.Command == CloseAllButThisCommand) + else if (e.Command == DocumentPaneCommands.CloseAllButThis) { CloseAllButThis(); e.Handled = true; } - else if (e.Command == NewHorizontalTabGroupCommand) + else if (e.Command == DocumentPaneCommands.NewHorizontalTabGroup) { - NewHorizontalTabGroup(); + CreateNewHorizontalTabGroup(); e.Handled = true; } - else if (e.Command == NewVerticalTabGroupCommand) + else if (e.Command == DocumentPaneCommands.NewVerticalTabGroup) { - NewVerticalTabGroup(); + CreateNewVerticalTabGroup(); e.Handled = true; } + //else if (e.Command == DocumentPaneCommands.ActivateDocument) + //{ + // ManagedContent doc = e.Parameter as ManagedContent; + // if (doc != null) + // { + // doc.Activate(); + // } + //} } - protected virtual void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + protected override void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = this.GetManager() != null; if (e.CanExecute) { - if (e.Command == NewHorizontalTabGroupCommand || - e.Command == NewVerticalTabGroupCommand) + if (e.Command == DocumentPaneCommands.NewHorizontalTabGroup || + e.Command == DocumentPaneCommands.NewVerticalTabGroup || + e.Command == DocumentPaneCommands.CloseAllButThis) { if (this.Items.Count <= 1) e.CanExecute = false; @@ -309,16 +260,42 @@ namespace AvalonDock } } + public void Close() + { + CloseThis(null); + } + + void CloseThis(ManagedContent contentToClose) + { + if (GetManager() == null) + return; + + if (contentToClose == null) + contentToClose = SelectedItem as ManagedContent; + + DockableContent dockableContent = contentToClose as DockableContent; + + if (dockableContent != null) + dockableContent.Close(); + else + { + DocumentContent documentContent = contentToClose as DocumentContent; + documentContent.Close(); + } + + } + void CloseAllButThis() { DocumentContent activeContent = GetManager().ActiveDocument as DocumentContent; - foreach (DocumentContent cnt in this.GetManager().Documents) + foreach (DocumentContent cnt in this.GetManager().Documents.ToArray()) { if (cnt != activeContent) cnt.Close(); } } - void NewHorizontalTabGroup() + + public DocumentPane CreateNewHorizontalTabGroup() { ManagedContent activeContent = SelectedItem as ManagedContent; DocumentPane newContainerPane = new DocumentPane(); @@ -329,8 +306,10 @@ namespace AvalonDock GetManager().Anchor(newContainerPane, this, AnchorStyle.Bottom); + return newContainerPane; } - void NewVerticalTabGroup() + + public DocumentPane CreateNewVerticalTabGroup() { ManagedContent activeContent = SelectedItem as ManagedContent; DocumentPane newContainerPane = new DocumentPane(); @@ -340,33 +319,38 @@ namespace AvalonDock newContainerPane.Items.Add(activeContent); GetManager().Anchor(newContainerPane, this, AnchorStyle.Right); + + return newContainerPane; } #endregion #endregion - UIElement _optionsContextMenuPlacementTarget; + Button _optionsContextMenuPlacementTarget; public override void OnApplyTemplate() { - _optionsContextMenuPlacementTarget = GetTemplateChild("PART_ShowContextMenuButton") as UIElement; + _optionsContextMenuPlacementTarget = GetTemplateChild("PART_ShowContextMenuButton") as Button; - + if (_optionsContextMenuPlacementTarget != null) + { + _optionsContextMenuPlacementTarget.Click += (s, e) => { ShowDocumentsListMenu(); }; + } base.OnApplyTemplate(); } - void ShowDocumentsListMenu(object sender, RoutedEventArgs e) + void ShowDocumentsListMenu() { if (Items.Count == 0) return; //nothings to show - ContextMenu cxMenuDocuments = (ContextMenu)FindResource("DocumentsListMenu"); + ContextMenu cxMenuDocuments = (ContextMenu)TryFindResource("DocumentsListMenu"); if (cxMenuDocuments != null) { - cxMenuDocuments.ItemsSource = Items; - cxMenuDocuments.CommandBindings.Add(new CommandBinding(ActivateDocumentCommand, new ExecutedRoutedEventHandler(this.ExecutedActivateDocumentCommand), new CanExecuteRoutedEventHandler(CanExecuteActivateDocumentCommand))); + cxMenuDocuments.ItemsSource = Items.OfType().OrderBy(c => c.Title); + //cxMenuDocuments.CommandBindings.Add(new CommandBinding(ActivateDocumentCommand, new ExecutedRoutedEventHandler(this.ExecutedActivateDocumentCommand), new CanExecuteRoutedEventHandler(CanExecuteActivateDocumentCommand))); if (_optionsContextMenuPlacementTarget != null) { @@ -382,19 +366,7 @@ namespace AvalonDock cxMenuDocuments.IsOpen = true; } } - - public override bool IsSurfaceVisible - { - get - { - if (IsMainDocumentPane.HasValue && - !IsMainDocumentPane.Value && - Items.Count == 0) - return false; - return true; - } - } protected override void OnMouseDown(MouseButtonEventArgs e) { @@ -466,21 +438,35 @@ namespace AvalonDock return parentPanel as DocumentPaneResizingPanel; } - public override Rect SurfaceRectangle + protected override bool IsSurfaceVisible + { + get + { + if (IsMainDocumentPane.HasValue && + !IsMainDocumentPane.Value && + Items.Count == 0) + return false; + + return true; + } + } + + protected override Rect SurfaceRectangle { get { + return base.SurfaceRectangle; //it is dragging a document let drop in this document pane - if (GetManager().DragPaneServices.FloatingWindow is DocumentFloatingWindow) - return base.SurfaceRectangle; + //if (GetManager().DragPaneServices.FloatingWindow is DocumentFloatingWindow) + // return base.SurfaceRectangle; - //otherwise we should provide a drop surface for all the DocumentPaneResizingPanel - DocumentPaneResizingPanel parentPanel = GetParentDocumentPaneResizingPanel(); + ////otherwise we should provide a drop surface for all the DocumentPaneResizingPanel + //DocumentPaneResizingPanel parentPanel = GetParentDocumentPaneResizingPanel(); - if (parentPanel == null) - return base.SurfaceRectangle; + //if (parentPanel == null) + // return base.SurfaceRectangle; - return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(parentPanel, new Point(0, 0)), new Size(parentPanel.ActualWidth, parentPanel.ActualHeight)); + //return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(parentPanel, new Point(0, 0)), new Size(parentPanel.ActualWidth, parentPanel.ActualHeight)); //return new Rect(parentPanel.PointToScreen(new Point(0, 0)), new Size(parentPanel.ActualWidth, parentPanel.ActualHeight)); } } @@ -501,9 +487,28 @@ namespace AvalonDock ((DockableContent)newItem).DockableStyle |= DockableStyle.Document; } + var dockContent = newItem as DockableContent; + if (dockContent != null) + dockContent.SetStateToDocument(); } } + RefreshContainsActiveDocumentProperty(); + + //if (Items.Count > 0 && + // SelectedItem == null && + // GetManager() != null) + //{ + // //get previously activated content + // var documentToActivate = Items.OrderBy(d => d.LastActivation).LastOrDefault(d => d != cntDeactivated); + + // Debug.WriteLine(string.Format("Activated Document '{0}'", documentToActivate != null ? documentToActivate.Title : "")); + + // if (documentToActivate != null) + // documentToActivate.Activate(); + // //ActiveDocument = MainDocumentPane.SelectedItem as ManagedContent; + //} + base.OnItemsChanged(e); } diff --git a/src/Libraries/AvalonDock/AvalonDock/DocumentPaneCommands.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentPaneCommands.cs new file mode 100644 index 0000000000..192ebc1871 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentPaneCommands.cs @@ -0,0 +1,142 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + public sealed class DocumentPaneCommands + { + private static object syncRoot = new object(); + + + private static RoutedUICommand closeAllButThisCommand = null; + public static RoutedUICommand CloseAllButThis + { + get + { + lock (syncRoot) + { + if (null == closeAllButThisCommand) + { + closeAllButThisCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DocumentPaneCommands_CloseAllButThis, "CloseAllButThis", typeof(DocumentPaneCommands)); + } + } + return closeAllButThisCommand; + } + } + + private static RoutedUICommand closeThisCommand = null; + public static RoutedUICommand CloseThis + { + get + { + lock (syncRoot) + { + if (null == closeThisCommand) + { + closeThisCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DocumentPaneCommands_CloseThis, "Close", typeof(DocumentPaneCommands)); + } + } + return closeThisCommand; + } + } + + private static RoutedUICommand newHTabGroupCommand = null; + public static RoutedUICommand NewHorizontalTabGroup + { + get + { + lock (syncRoot) + { + if (null == newHTabGroupCommand) + { + newHTabGroupCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DocumentPaneCommands_NewHorizontalTabGroup, "NewHorizontalTabGroup", typeof(DocumentPaneCommands)); + } + } + return newHTabGroupCommand; + } + } + + private static RoutedUICommand newVTabGroupCommand = null; + public static RoutedUICommand NewVerticalTabGroup + { + get + { + lock (syncRoot) + { + if (null == newVTabGroupCommand) + { + newVTabGroupCommand = new RoutedUICommand(AvalonDock.Properties.Resources.DocumentPaneCommands_NewVerticalTabGroup, "NewVerticalTabGroup", typeof(DocumentPaneCommands)); + } + } + return newVTabGroupCommand; + } + } + + + //private static RoutedUICommand activateDocument = null; + //public static RoutedUICommand ActivateDocument + //{ + // get + // { + // lock (syncRoot) + // { + // if (null == activateDocument) + // { + // activateDocument = new RoutedUICommand("Activate Document", "ActivateDocuement", typeof(DocumentPaneCommands)); + // } + // } + // return activateDocument; + // } + //} + + //#region Activate Document Command + //public static RoutedCommand ActivateDocumentCommand = new RoutedCommand(); + + //public void ExecutedActivateDocumentCommand(object sender, + // ExecutedRoutedEventArgs e) + //{ + // ManagedContent doc = e.Parameter as ManagedContent; + // if (doc != null) + // { + // doc.Activate(); + // } + //} + + //public void CanExecuteActivateDocumentCommand(object sender, + // CanExecuteRoutedEventArgs e) + //{ + // e.CanExecute = true; + //} + + //#endregion + + } +} diff --git a/src/Libraries/AvalonDock/DocumentPaneResizingPanel.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentPaneResizingPanel.cs similarity index 97% rename from src/Libraries/AvalonDock/DocumentPaneResizingPanel.cs rename to src/Libraries/AvalonDock/AvalonDock/DocumentPaneResizingPanel.cs index 2eeb3c6988..64d7d91512 100644 --- a/src/Libraries/AvalonDock/DocumentPaneResizingPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentPaneResizingPanel.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, diff --git a/src/Libraries/AvalonDock/DocumentTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs similarity index 75% rename from src/Libraries/AvalonDock/DocumentTabPanel.cs rename to src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs index 036691b0f2..65226ee9fc 100644 --- a/src/Libraries/AvalonDock/DocumentTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DocumentTabPanel.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -61,20 +61,22 @@ namespace AvalonDock protected override Size MeasureOverride(Size availableSize) { - Size desideredSize = new Size(0, availableSize.Height); + Size desideredSize = new Size(); int i = 1; foreach (ManagedContent child in Children) { Panel.SetZIndex(child, Selector.GetIsSelected(child)?1:-i); i++; - child.Width = double.NaN; - child.Height = double.NaN; - child.Measure(new Size(double.PositiveInfinity, availableSize.Height)); + //child.Width = double.NaN; + //child.Height = double.NaN; + child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); desideredSize.Width += child.DesiredSize.Width; + desideredSize.Height = Math.Max(desideredSize.Height, child.DesiredSize.Height); } - return base.MeasureOverride(availableSize); + return new Size(Math.Min(desideredSize.Width, availableSize.Width), desideredSize.Height); + //return base.MeasureOverride(availableSize); //return desideredSize; } @@ -101,5 +103,29 @@ namespace AvalonDock return finalSize; } + + //#region Padding + + ///// + ///// Padding Dependency Property + ///// + //public static readonly DependencyProperty PaddingProperty = + // DependencyProperty.Register("Padding", typeof(Thickness), typeof(DocumentTabPanel), + // new FrameworkPropertyMetadata((Thickness)new Thickness(), + // FrameworkPropertyMetadataOptions.AffectsMeasure)); + + ///// + ///// Gets or sets the Padding property. This dependency property + ///// indicates internal padding of the panel. + ///// + //public Thickness Padding + //{ + // get { return (Thickness)GetValue(PaddingProperty); } + // set { SetValue(PaddingProperty, value); } + //} + + //#endregion + + } } diff --git a/src/Libraries/AvalonDock/DragPaneServices.cs b/src/Libraries/AvalonDock/AvalonDock/DragPaneServices.cs similarity index 90% rename from src/Libraries/AvalonDock/DragPaneServices.cs rename to src/Libraries/AvalonDock/AvalonDock/DragPaneServices.cs index e9b936a3d4..bca01d5496 100644 --- a/src/Libraries/AvalonDock/DragPaneServices.cs +++ b/src/Libraries/AvalonDock/AvalonDock/DragPaneServices.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -28,6 +28,7 @@ using System.Collections.Generic; using System.Text; using System.Windows; using System.Diagnostics; +using System.ComponentModel; namespace AvalonDock { @@ -48,6 +49,12 @@ namespace AvalonDock public DragPaneServices(DockingManager owner) { + if (DesignerProperties.GetIsInDesignMode(owner)) + throw new NotSupportedException("DragPaneServices not valid in design mode"); + + if (owner == null) + throw new ArgumentNullException("owner"); + _owner = owner; } @@ -63,10 +70,15 @@ namespace AvalonDock } Point Offset; - + + public bool IsDragging { get; private set; } public void StartDrag(FloatingWindow wnd, Point point, Point offset) { + Debug.Assert(!IsDragging); + + IsDragging = true; + Offset = offset; _wnd = wnd; @@ -162,9 +174,15 @@ namespace AvalonDock if (dropSufrace != null) _wnd.Close(); else + { + _wnd.Visibility = Visibility.Visible; _wnd.Activate(); + } _wnd = null; + + IsDragging = false; + } FloatingWindow _wnd; diff --git a/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs b/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs new file mode 100644 index 0000000000..1751b0c877 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/FloatingDockablePane.cs @@ -0,0 +1,216 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Linq; +using System.Windows.Data; + +namespace AvalonDock +{ + public class FloatingDockablePane : DockablePane + { + static FloatingDockablePane() + { + //DefaultStyleKeyProperty.OverrideMetadata(typeof(FloatingDockablePane), new FrameworkPropertyMetadata(typeof(FloatingDockablePane))); + //by design avoid style change + + Pane.ShowHeaderProperty.OverrideMetadata(typeof(FloatingDockablePane), new FrameworkPropertyMetadata(false)); + + } + + + + internal FloatingDockablePane(DockableFloatingWindow floatingWindow, DockablePane paneToTransfer) + { + _floatingWindow = floatingWindow; + _paneToTransfer = paneToTransfer; + } + + internal FloatingDockablePane(DockableFloatingWindow floatingWindow, DockableContent contentToTransfer) + { + _floatingWindow = floatingWindow; + _contentToTransfer = contentToTransfer; + } + + protected override void OnInitialized(EventArgs e) + { + if (_paneToTransfer != null) + { + //setup window size + ManagedContent selectedContent = _paneToTransfer.SelectedItem as ManagedContent; + if (selectedContent is DockableContent) + { + _floatingWindow.SizeToContent = (selectedContent as DockableContent).FloatingWindowSizeToContent; + } + + if (selectedContent != null && selectedContent.FloatingWindowSize.IsEmpty) + selectedContent.FloatingWindowSize = new Size(_paneToTransfer.ActualWidth, _paneToTransfer.ActualHeight); + + if (selectedContent != null) + { + _floatingWindow.Width = selectedContent.FloatingWindowSize.Width; + _floatingWindow.Height = selectedContent.FloatingWindowSize.Height; + } + else + { + _floatingWindow.Width = _paneToTransfer.ActualWidth; + _floatingWindow.Height = _paneToTransfer.ActualHeight; + } + + int selectedIndex = _paneToTransfer.SelectedIndex; + + //remove contents from container pane and insert in hosted pane + while (_paneToTransfer.Items.Count > 0) + { + DockableContent contentToTranser = _paneToTransfer.Items[0] as DockableContent; + + contentToTranser.SaveCurrentStateAndPosition(); + + _paneToTransfer.RemoveContent(0); + + //add content to my temporary pane + Items.Add(contentToTranser); + + contentToTranser.SetStateToDockableWindow(); + } + + SelectedIndex = selectedIndex; + + //transfer the style from the original dockablepane + //Style = _paneToTransfer.Style; + AttachStyleFromPane(_paneToTransfer); + + ApplyTemplate(); + } + else if (_contentToTransfer != null) + { + //setup window size + if (_contentToTransfer.FloatingWindowSize.IsEmpty) + _contentToTransfer.FloatingWindowSize = new Size(_contentToTransfer.ContainerPane.ActualWidth, _contentToTransfer.ContainerPane.ActualHeight); + + _floatingWindow.Width = _contentToTransfer.FloatingWindowSize.Width; + _floatingWindow.Height = _contentToTransfer.FloatingWindowSize.Height; + + //save current content position in container pane + _previousPane = _contentToTransfer.ContainerPane; + + _arrayIndexPreviousPane = _previousPane.Items.IndexOf(_contentToTransfer); + + _contentToTransfer.SaveCurrentStateAndPosition(); + + //remove content from container pane + _contentToTransfer.ContainerPane.RemoveContent(_arrayIndexPreviousPane); + + //add content to this pane + Items.Add(_contentToTransfer); + + SelectedIndex = 0; + + //if (_previousPane is DockablePane) + //{ + // Style = _previousPane.Style; + //} + AttachStyleFromPane(_previousPane as DockablePane); + + DocumentPane originalDocumentPane = _previousPane as DocumentPane; + if (originalDocumentPane != null) + originalDocumentPane.CheckContentsEmpty(); + + + _contentToTransfer.SetStateToDockableWindow(); + } + + base.OnInitialized(e); + } + + void AttachStyleFromPane(DockablePane copyFromPane) + { + if (copyFromPane == null) + return; + + Binding bnd = new Binding("Style"); + bnd.Source = copyFromPane; + bnd.Mode = BindingMode.OneWay; + + SetBinding(StyleProperty, bnd); + } + + DockablePane _paneToTransfer = null; + DockableContent _contentToTransfer = null; + + Pane _previousPane = null; + int _arrayIndexPreviousPane = -1; + + DockableFloatingWindow _floatingWindow = null; + + public DockableFloatingWindow FloatingWindow + { + get { return _floatingWindow; } + } + + public override DockingManager GetManager() + { + return _floatingWindow.Manager; + } + + protected override void CheckItems(System.Collections.IList newItems) + { + if (Items.Count == 0 && FloatingWindow != null) + FloatingWindow.Close(true); + } + + protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + if (e.NewItems != null) + { + e.NewItems.Cast().ForEach(c => + { + if (c.State == DockableContentState.None) + { + if (FloatingWindow.IsDockableWindow) + c.SetStateToDockableWindow(); + else + c.SetStateToFloatingWindow(); + } + }); + } + + base.OnItemsChanged(e); + } + + public override void Dock() + { + DockableContent[] contentsToRedock = Items.Cast().ToArray(); + + foreach (var cntToRedock in contentsToRedock) + cntToRedock.Show(); + + base.Dock(); + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs b/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs new file mode 100644 index 0000000000..993a480292 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/FloatingDocumentPane.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Data; + +namespace AvalonDock +{ + internal class FloatingDocumentPane : DocumentPane + { + static FloatingDocumentPane() + { + Pane.ShowHeaderProperty.OverrideMetadata(typeof(FloatingDocumentPane), new FrameworkPropertyMetadata(false)); + } + + internal FloatingDocumentPane(DocumentFloatingWindow floatingWindow, DocumentContent documentToTransfer) + { + _floatingWindow = floatingWindow; + _documentToTransfer = documentToTransfer; + } + + DocumentContent _documentToTransfer = null; + DocumentPane _previousPane = null; + + internal DocumentPane PreviousPane + { + get + { return _previousPane; } + } + + int _arrayIndexPreviousPane = -1; + + internal int ArrayIndexPreviousPane + { + get { return _arrayIndexPreviousPane; } + } + + protected override void OnInitialized(EventArgs e) + { + //setup window size + _floatingWindow.Width = _documentToTransfer.ContainerPane.ActualWidth; + _floatingWindow.Height = _documentToTransfer.ContainerPane.ActualHeight; + + //save current content position in container pane + _previousPane = _documentToTransfer.ContainerPane as DocumentPane; + _arrayIndexPreviousPane = _previousPane.Items.IndexOf(_documentToTransfer); + SetValue(ResizingPanel.ResizeWidthProperty, _previousPane.GetValue(ResizingPanel.ResizeWidthProperty)); + SetValue(ResizingPanel.ResizeHeightProperty, _previousPane.GetValue(ResizingPanel.ResizeHeightProperty)); + + //Style = _previousPane.Style; + AttachStyleFromPane(_previousPane); + + //remove content from container pane + _previousPane.RemoveContent(_arrayIndexPreviousPane); + + //add content to my temporary pane + Items.Add(_documentToTransfer); + + _documentToTransfer.SetIsFloating(true); + + base.OnInitialized(e); + } + + void AttachStyleFromPane(DocumentPane copyFromPane) + { + if (copyFromPane == null) + return; + + Binding bnd = new Binding("Style"); + bnd.Source = copyFromPane; + bnd.Mode = BindingMode.OneWay; + + SetBinding(StyleProperty, bnd); + } + + protected override void OnUnloaded(object sender, RoutedEventArgs e) + { + _documentToTransfer.SetIsFloating(false); + base.OnUnloaded(sender, e); + } + + + DocumentFloatingWindow _floatingWindow = null; + + public DocumentFloatingWindow FloatingWindow + { + get { return _floatingWindow; } + } + + public override DockingManager GetManager() + { + return _floatingWindow.Manager; + } + + protected override bool IsSurfaceVisible + { + get + { + return false; + } + } + + protected override void CheckItems(System.Collections.IList newItems) + { + foreach (object newItem in newItems) + { + if (!(newItem is DocumentContent)) + throw new InvalidOperationException("FloatingDocumentPane can contain only DocumentContents!"); + } + + if (Items.Count == 0 && FloatingWindow != null) + FloatingWindow.Close(true); + } + + public override void Dock() + { + var contentsToRedock = Items.Cast().ToArray(); + + foreach (var cntToRedock in contentsToRedock) + cntToRedock.Show(); + + base.Dock(); + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs b/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs new file mode 100644 index 0000000000..993de8ee3a --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/FloatingWindow.cs @@ -0,0 +1,617 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Markup; +using System.Diagnostics; +using System.Windows.Threading; +using System.Windows.Media.Animation; +using System.Windows.Interop; +using System.Runtime.InteropServices; +using System.Linq; + +namespace AvalonDock +{ + /// + /// Represents the base class for and classes + /// + /// Provides base services for floating windows + public abstract class FloatingWindow : AvalonDockWindow + { + static FloatingWindow() + { + Window.ShowInTaskbarProperty.OverrideMetadata(typeof(FloatingWindow), new FrameworkPropertyMetadata(false)); + Window.WindowStyleProperty.OverrideMetadata(typeof(FloatingWindow), new FrameworkPropertyMetadata(WindowStyle.ToolWindow)); + + //DefaultStyleKeyProperty.OverrideMetadata(typeof(FloatingWindow), new FrameworkPropertyMetadata(typeof(FloatingWindow))); + } + + + internal FloatingWindow() + { + this.Loaded += new RoutedEventHandler(OnLoaded); + this.Unloaded += new RoutedEventHandler(OnUnloaded); + + this.SizeChanged += new SizeChangedEventHandler(FloatingWindow_SizeChanged); + } + + internal FloatingWindow(DockingManager manager) + : this() + { + //save manager ref + _manager = manager; + } + + void FloatingWindow_SizeChanged(object sender, SizeChangedEventArgs e) + { + if (HostedPane != null) + { + foreach (ManagedContent c in HostedPane.Items) + c.FloatingWindowSize = new Size(Width, Height); + + ResizingPanel.SetEffectiveSize(HostedPane, new Size(Width, Height)); + } + } + + DockingManager _manager = null; + + internal DockingManager Manager + { + get { return _manager; } + } + + public Pane HostedPane + { + get { return Content as Pane; } + } + + #region ContentTitle + + /// + /// ContentTitle Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey ContentTitlePropertyKey + = DependencyProperty.RegisterReadOnly("ContentTitle", typeof(object), typeof(FloatingWindow), + new FrameworkPropertyMetadata((object)null)); + + public static readonly DependencyProperty ContentTitleProperty + = ContentTitlePropertyKey.DependencyProperty; + + /// + /// Gets the ContentTitle property. This dependency property + /// indicates title of the content currectly hosted in the floating window. + /// + public object ContentTitle + { + get { return (object)GetValue(ContentTitleProperty); } + } + + /// + /// Provides a secure method for setting the ContentTitle property. + /// This dependency property indicates title of the content currectly hosted in the floating window. + /// + /// The new value for the property. + protected void SetContentTitle(object value) + { + SetValue(ContentTitlePropertyKey, value); + } + + + private void UpdateContentTitle() + { + if (HostedPane == null) + return; + + var cnt = HostedPane.SelectedItem as ManagedContent; + if (cnt != null) + SetContentTitle(cnt.Title); + } + #endregion + + + + //#region HostedPane + + ///// + ///// HostedPane Read-Only Dependency Property + ///// + //private static readonly DependencyPropertyKey HostedPanePropertyKey + // = DependencyProperty.RegisterReadOnly("HostedPane", typeof(Pane), typeof(FloatingWindow), + // new FrameworkPropertyMetadata((Pane)null, + // new PropertyChangedCallback(OnHostedPaneChanged))); + + //public static readonly DependencyProperty HostedPaneProperty + // = HostedPanePropertyKey.DependencyProperty; + + ///// + ///// Gets the HostedPane property. This dependency property + ///// indicates the hosted pane contained into the floating window (an hosted pane can be of type or type . + ///// + //public Pane HostedPane + //{ + // get { return (Pane)GetValue(HostedPaneProperty); } + //} + + ///// + ///// Provides a secure method for setting the HostedPane property. + ///// This dependency property indicates the hosted pane contained into the floating window (an hosted pane can be of type or type . + ///// + ///// The new value for the property. + //protected void SetHostedPane(Pane value) + //{ + // SetValue(HostedPanePropertyKey, value); + //} + + ///// + ///// Handles changes to the HostedPane property. + ///// + //private static void OnHostedPaneChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + //{ + // ((FloatingWindow)d).OnHostedPaneChanged(e); + //} + + ///// + ///// Provides derived classes an opportunity to handle changes to the HostedPane property. + ///// + //protected virtual void OnHostedPaneChanged(DependencyPropertyChangedEventArgs e) + //{ + //} + + //#endregion + + protected override void OnInitialized(EventArgs e) + { + + base.OnInitialized(e); + } + + protected override void OnContentChanged(object oldContent, object newContent) + { + base.OnContentChanged(oldContent, newContent); + + if (_manager != null) + { + _manager.RegisterFloatingWindow(this); + _manager.RefreshContents(); + } + + UpdateContentTitle(); + } + + + + internal virtual void OnEndDrag() + { + } + + internal virtual void OnShowSelectionBox() + { + + } + + internal virtual void OnHideSelectionBox() + { + + } + + #region Move/Resize + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + Resizer resLeftAnchor = GetTemplateChild("PART_LeftAnchor") as Resizer; + Resizer resTopAnchor = GetTemplateChild("PART_TopAnchor") as Resizer; + Resizer resBottomAnchor = GetTemplateChild("PART_BottomAnchor") as Resizer; + Resizer resRightAnchor = GetTemplateChild("PART_RightAnchor") as Resizer; + + Resizer resLeftTopAnchor = GetTemplateChild("PART_LeftTopAnchor") as Resizer; + Resizer resLeftBottomAnchor = GetTemplateChild("PART_LeftBottomAnchor") as Resizer; + + Resizer resRightTopAnchor = GetTemplateChild("PART_RightTopAnchor") as Resizer; + Resizer resRightBottomAnchor = GetTemplateChild("PART_RightBottomAnchor") as Resizer; + + //Resizer resMoveAnchor = GetTemplateChild("PART_MoveAnchor") as Resizer; + Border resMoveAnchor = GetTemplateChild("PART_MoveAnchor") as Border; + + if (resLeftAnchor != null) resLeftAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinWidth, Width - e.HorizontalChange) - Width; + this.Left -= delta; + this.Width += delta; + }; + if (resRightAnchor != null) resRightAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinWidth, Width + e.HorizontalChange) - Width; + this.Width += delta; + }; + if (resTopAnchor != null) resTopAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinHeight, Height - e.VerticalChange) - Height; + this.Top -= delta; + this.Height += delta; + }; + if (resBottomAnchor != null) resBottomAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinHeight, Height + e.VerticalChange) - Height; + this.Height += delta; + }; + + if (resLeftTopAnchor != null) resLeftTopAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinWidth, Width - e.HorizontalChange) - Width; + this.Left -= delta; + this.Width += delta; + + delta = Math.Max(MinHeight, Height - e.VerticalChange) - Height; + this.Top -= delta; + this.Height += delta; + }; + if (resLeftBottomAnchor != null) resLeftBottomAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinWidth, Width - e.HorizontalChange) - Width; + this.Left -= delta; + this.Width += delta; + + delta = Math.Max(MinHeight, Height + e.VerticalChange) - Height; + this.Height += delta; + }; + if (resRightTopAnchor != null) resRightTopAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinWidth, Width + e.HorizontalChange) - Width; + this.Width += delta; + + delta = Math.Max(MinHeight, Height - e.VerticalChange) - Height; + this.Top -= delta; + this.Height += delta; + }; + if (resRightBottomAnchor != null) resRightBottomAnchor.DragDelta += (s, e) => + { + double delta = Math.Max(MinWidth, Width + e.HorizontalChange) - Width; + this.Width += delta; + + delta = Math.Max(MinHeight, Height + e.VerticalChange) - Height; + this.Height += delta; + }; + + if (resMoveAnchor != null) + { + bool isMouseDown = false; + Point ptStartDrag = new Point(); + resMoveAnchor.MouseLeftButtonDown += (s, e) => + { + isMouseDown = true; + ptStartDrag = e.GetPosition(s as IInputElement); + resMoveAnchor.CaptureMouse(); + }; + + resMoveAnchor.MouseMove += (s, e) => + { + if (isMouseDown && resMoveAnchor.IsMouseCaptured) + { + Point ptMouseMove = e.GetPosition(s as IInputElement); + if (Math.Abs(ptMouseMove.X - ptStartDrag.X) > SystemParameters.MinimumHorizontalDragDistance || + Math.Abs(ptMouseMove.Y - ptStartDrag.Y) > SystemParameters.MinimumVerticalDragDistance) + { + isMouseDown = false; + resMoveAnchor.ReleaseMouseCapture(); + HandleMove(); + } + } + }; + + resMoveAnchor.MouseLeftButtonUp += (s, e)=> + { + isMouseDown = false; + resMoveAnchor.ReleaseMouseCapture(); + }; + + } + + var pupupButton = GetTemplateChild("PART_ShowContextMenuButton") as FrameworkElement; + + if (pupupButton != null) + pupupButton.MouseLeftButtonDown += (s, e) => + { + e.Handled = OpenContextMenu(s as Border, e.GetPosition(s as IInputElement)); + }; + + var titleAnchor = GetTemplateChild("PART_MoveAnchor") as FrameworkElement; + if (titleAnchor != null) + titleAnchor.MouseRightButtonDown += (s, e) => + { + e.Handled = OpenContextMenu(s as Border, e.GetPosition(s as IInputElement)); + }; + + + base.OnApplyTemplate(); + } + + protected virtual bool OpenContextMenu(UIElement popupButton, Point ptMouse) + { + return false; + } + + protected virtual void HandleMove() + { + Point mousePosition = PointToScreen(Mouse.GetPosition(null)); + Point clickPoint = this.TransformToDeviceDPI(mousePosition); + if (!Manager.DragPaneServices.IsDragging) + Manager.Drag(this, clickPoint, new Point(clickPoint.X - Left, clickPoint.Y - Top)); + } + + #endregion + + #region Active Content Management + ManagedContent lastActiveContent = null; + + protected override void OnActivated(EventArgs e) + { + if (Manager != null) + { + lastActiveContent = Manager.ActiveContent; + Manager.ActiveContent = HostedPane.SelectedItem as ManagedContent; + } + + base.OnActivated(e); + } + + protected override void OnDeactivated(EventArgs e) + { + if (Manager != null && lastActiveContent != null) + { + Manager.ActiveContent = lastActiveContent; + } + base.OnDeactivated(e); + } + #endregion + + #region IsClosing Flag Management + + /// + /// Closes the window regardless of result of contents CanClose method call + /// + /// + internal void Close(bool force) + { + ForcedClosing = force; + base.Close(); + } + + protected bool ForcedClosing { get; private set; } + + internal bool IsClosing { get; private set; } + + protected override void OnClosing(CancelEventArgs e) + { + IsClosing = true; + + if (HostedPane.Items.Count > 0) + { + var contentsToClose = HostedPane.Items.Cast().ToArray(); + foreach (var cntToClose in contentsToClose) + { + //if even a content can't close than cancel the close process, but continue try closing other contents + if (!cntToClose.Close()) + { + //forced closing continues the window close process + if (!ForcedClosing) + e.Cancel = true; + } + } + } + + if (e.Cancel) + IsClosing = false; + else if (_manager != null) + { + _manager.UnregisterFloatingWindow(this); + } + + base.OnClosing(e); + } + + protected override void OnClosed(EventArgs e) + { + IsClosing = false; + base.OnClosed(e); + } + #endregion + + public abstract Pane ClonePane(); + + + #region Enable/Disable window Close Button + [DllImport("User32.dll", CharSet = CharSet.Auto)] + private static extern IntPtr GetSystemMenu( + IntPtr hWnd, + Int32 bRevert + ); + + [DllImport("User32.dll", CharSet = CharSet.Auto)] + private static extern int GetMenuItemCount( + IntPtr hMenu + ); + + [DllImport("User32.dll", CharSet = CharSet.Auto)] + private static extern int DrawMenuBar( + IntPtr hWnd + ); + + [DllImport("User32.dll", CharSet = CharSet.Auto)] + private static extern bool EnableMenuItem( + IntPtr hMenu, + Int32 uIDEnableItem, + Int32 uEnable + ); + + private const Int32 MF_BYPOSITION = 0x400; + private const Int32 MF_ENABLED = 0x0000; + private const Int32 MF_GRAYED = 0x0001; + private const Int32 MF_DISABLED = 0x0002; + + void EnableXButton() + { + WindowInteropHelper helper = new WindowInteropHelper(this); + IntPtr hMenu = GetSystemMenu(helper.Handle, 0); + + int menuItemCount = GetMenuItemCount(hMenu); + + EnableMenuItem(hMenu, menuItemCount - 1, MF_BYPOSITION | MF_ENABLED); + DrawMenuBar(helper.Handle); + } + + void DisableXButton() + { + WindowInteropHelper helper = new WindowInteropHelper(this); + IntPtr hMenu = GetSystemMenu(helper.Handle, 0); + + int menuItemCount = GetMenuItemCount(hMenu); + + EnableMenuItem(hMenu, menuItemCount - 1, MF_BYPOSITION | MF_DISABLED | MF_GRAYED); + DrawMenuBar(helper.Handle); + } + + #endregion + + #region Non-Client area management + + protected const int WM_MOVE = 0x0003; + protected const int WM_SIZE = 0x0005; + protected const int WM_NCMOUSEMOVE = 0xa0; + protected const int WM_NCLBUTTONDOWN = 0xA1; + protected const int WM_NCLBUTTONUP = 0xA2; + protected const int WM_NCLBUTTONDBLCLK = 0xA3; + protected const int WM_NCRBUTTONDOWN = 0xA4; + protected const int WM_NCRBUTTONUP = 0xA5; + protected const int HTCAPTION = 2; + protected const int SC_MOVE = 0xF010; + protected const int WM_SYSCOMMAND = 0x0112; + + + + #region Load/Unload window events + + + protected void OnLoaded(object sender, EventArgs e) + { + WindowInteropWrapper wih = new WindowInteropWrapper(this); + + //wih.WindowActivating += (s, ce) => ce.Cancel = true;//prevent window activating + wih.FilterMessage += new EventHandler(FilterMessage); + + if (HostedPane.Items.Count > 0) + { + ManagedContent cntHosted = HostedPane.Items[0] as ManagedContent; + if (!cntHosted.IsCloseable) + { + DisableXButton(); + } + } + } + + protected void OnUnloaded(object sender, EventArgs e) + { } + #endregion + + + protected virtual void FilterMessage(object sender, FilterMessageEventArgs e) + { + if (e.Handled) + return; + + if (Manager == null) + return; + + switch (e.Msg) + { + case WM_SIZE: + case WM_MOVE: + break; + case WM_NCRBUTTONDOWN: //Right button click on title area -> show context menu + if (e.WParam.ToInt32() == HTCAPTION) + { + short x = (short)((e.LParam.ToInt32() & 0xFFFF)); + short y = (short)((e.LParam.ToInt32() >> 16)); + OpenContextMenu(null, new Point(x, y)); + e.Handled = true; + } + break; + case WM_NCRBUTTONUP: //set as handled right button click on title area (after showing context menu) + if (e.WParam.ToInt32() == HTCAPTION) + { + e.Handled = true; + } + break; + + } + + } + #endregion + + #region Floating/dockable window state + + + /// + /// Redock contained object to the + /// + public virtual void Dock() + { + + } + #endregion + + + + internal void CheckContents() + { + if (HostedPane == null) + return; + + ManagedContent[] cntsToCheck = HostedPane.Items.Cast().ToArray(); + + cntsToCheck.ForEach(cnt => + { + if (cnt.Manager == null || + cnt.Manager != Manager || + (!cnt.Manager.DockableContents.Contains(cnt) && + !cnt.Manager.Documents.Contains(cnt))) + cnt.ContainerPane.RemoveContent(cnt); + }); + } + } +} diff --git a/src/Libraries/AvalonDock/FlyoutDockablePane.cs b/src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs similarity index 86% rename from src/Libraries/AvalonDock/FlyoutDockablePane.cs rename to src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs index 6b75057884..188f46a5c5 100644 --- a/src/Libraries/AvalonDock/FlyoutDockablePane.cs +++ b/src/Libraries/AvalonDock/AvalonDock/FlyoutDockablePane.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -56,12 +56,6 @@ namespace AvalonDock SetValue(ResizingPanel.ResizeWidthProperty, new GridLength(ResizingPanel.GetEffectiveSize(_referencedPane).Width)); SetValue(ResizingPanel.ResizeHeightProperty, new GridLength(ResizingPanel.GetEffectiveSize(_referencedPane).Height)); - - //if (double.IsInfinity(ResizingPanel.GetResizeWidth(this))) - // ResizingPanel.SetResizeWidth(this, 200); - //if (double.IsInfinity(ResizingPanel.GetResizeHeight(this))) - // ResizingPanel.SetResizeHeight(this, 200); - this.Style = _referencedPane.Style; //remove content from container pane @@ -92,6 +86,11 @@ namespace AvalonDock DockablePane _referencedPane = null; + internal DockablePane ReferencedPane + { + get { return _referencedPane; } + } + DockingManager _manager = null; public override DockingManager GetManager() @@ -99,15 +98,9 @@ namespace AvalonDock return _manager; } - internal override void ToggleAutoHide() + public override void ToggleAutoHide() { GetManager().ToggleAutoHide(_referencedPane); } - //internal override void Close() - //{ - // DockingManager manager = GetManager(); - // if (manager != null) - // Manager.Hide(SelectedItem as DockableContent); - //} } } diff --git a/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs b/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs new file mode 100644 index 0000000000..28a51d7a68 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/FlyoutPaneWindow.cs @@ -0,0 +1,1107 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Windows.Markup; +using System.Diagnostics; +using System.Windows.Threading; +using System.Windows.Media.Animation; +using System.Windows.Forms.Integration; +using System.Runtime.InteropServices; +using System.Windows.Interop; +using System.Threading; + +namespace AvalonDock +{ + /// + /// Implements a flyout window + /// + /// + /// The flyout window is showed when user activate a ManagedContent that is in the AutoHide state. + /// The flyout window appears from a border of the parent docking manager according to the property Anchor. + /// It contains the selected content under the property ReferencedPane. + /// When user move focus to an other object outside this window, it automaticcaly is closed. + /// + [ContentPropertyAttribute("ReferencedPane")] + public class FlyoutPaneWindow : AvalonDockWindow + { + /// + /// Points to the internal windows forms control (if exist) + /// + WindowsFormsHost _winFormsHost = null; + + double _targetWidth; + double _targetHeight; + + /// + /// Gets or sets the final width of the window + /// + internal double TargetWidth + { + get { return _targetWidth; } + set { _targetWidth = value; } + } + + /// + /// Gets or sets the final height of the window + /// + internal double TargetHeight + { + get { return _targetHeight; } + set { _targetHeight = value; } + } + + DockingManager _dockingManager = null; + + internal DockablePaneAnchorTab AnchorTabActivating { get; set; } + + static FlyoutPaneWindow() + { + //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. + //This style is defined in themes\generic.xaml + DefaultStyleKeyProperty.OverrideMetadata(typeof(FlyoutPaneWindow), new FrameworkPropertyMetadata(typeof(FlyoutPaneWindow))); + + //AllowsTransparency slow down perfomance under XP/VISTA because rendering is enterely perfomed using CPU + //Window.AllowsTransparencyProperty.OverrideMetadata(typeof(FlyoutPaneWindow), new FrameworkPropertyMetadata(true)); + + WindowStyleProperty.OverrideMetadata(typeof(FlyoutPaneWindow), new FrameworkPropertyMetadata(WindowStyle.None)); + ShowInTaskbarProperty.OverrideMetadata(typeof(FlyoutPaneWindow), new FrameworkPropertyMetadata(false)); + ResizeModeProperty.OverrideMetadata(typeof(FlyoutPaneWindow), new FrameworkPropertyMetadata(ResizeMode.NoResize)); + BackgroundProperty.OverrideMetadata(typeof(FlyoutPaneWindow), new FrameworkPropertyMetadata(Brushes.Transparent)); + } + + public FlyoutPaneWindow() + { + Title = "AvalonDock_FlyoutPaneWindow"; + } + + public FlyoutPaneWindow(DockingManager manager, DockableContent content) + : this() + { + //create a new temporary pane + _refPane = new FlyoutDockablePane(content); + _dockingManager = manager; + + _winFormsHost = ReferencedPane.GetLogicalChildContained(); + + if (_winFormsHost != null) + { + AllowsTransparency = false; + } + + this.Loaded += new RoutedEventHandler(FlyoutPaneWindow_Loaded); + } + + + void FlyoutPaneWindow_Loaded(object sender, RoutedEventArgs e) + { + //prevents user from activating this window + //WindowInteropWrapper wiw = new WindowInteropWrapper(this); + //wiw.WindowActivating += (s, args) => args.Cancel = true; + + //Open the pane with or without animation + OpenPane(); + } + + + public override void OnApplyTemplate() + { + var resizer = GetTemplateChild("PART_Resizer") as Resizer; + + if (resizer != null) resizer.DragStarted += (s, e) => + { + IsResizing = true; + + ShowResizerOverlayWindow(s as Resizer); + }; + + if (resizer != null) resizer.DragDelta += (s, e) => + { + switch (CorrectedAnchor) + { + case AnchorStyle.Left: + case AnchorStyle.Right: + { + double newLeft = _initialStartPoint.X + e.HorizontalChange; + newLeft = Math.Max(newLeft, 0.0); + newLeft = Math.Min(newLeft, MaxWidth); + + Canvas.SetLeft(_resizerGhost, newLeft); + } + break; + case AnchorStyle.Top: + case AnchorStyle.Bottom: + { + double newTop = _initialStartPoint.Y + e.VerticalChange; + newTop = Math.Max(newTop, 0.0); + newTop = Math.Min(newTop, MaxHeight); + + Canvas.SetTop(_resizerGhost, newTop); + } + break; + + } + }; + + if (resizer != null) resizer.DragCompleted += (s, e) => + { + switch (CorrectedAnchor) + { + case AnchorStyle.Left: + { + Width = Canvas.GetLeft(_resizerGhost) + _resizerGhost.Width; + ApplyRegion(new Rect(0, 0, this.Width, this.Height)); + } + break; + case AnchorStyle.Right: + { + double newWidth = MaxWidth - Canvas.GetLeft(_resizerGhost); + Left -= newWidth - Width; + Width = newWidth; + + + ApplyRegion(new Rect(0, 0, this.Width, this.Height)); + } + break; + case AnchorStyle.Top: + { + Height = Canvas.GetTop(_resizerGhost) + _resizerGhost.Height; + ApplyRegion(new Rect(0, 0, this.Width, this.Height)); + } + break; + case AnchorStyle.Bottom: + { + double newHeight = MaxHeight - Canvas.GetTop(_resizerGhost); + Top -= newHeight - Height; + Height = newHeight; + + + ApplyRegion(new Rect(0, 0, this.Width, this.Height)); + } + break; + } + + IsResizing = false; + HideResizerOverlayWindow(); + }; + + + + base.OnApplyTemplate(); + } + + + /// + /// Handles the closed event + /// + /// + protected override void OnClosed(EventArgs e) + { + StopClosingTimer(); + + ReferencedPane.RestoreOriginalPane(); + + base.OnClosed(e); + + IsClosed = true; + } + + /// + /// Gets a value indicating i fthis window is closed + /// + internal bool IsClosed { get; private set; } + + /// + /// Anchor of the flyout window + /// + public AnchorStyle Anchor + { + get { return ReferencedPane.Anchor; } + } + + /// + /// Get th anchor of the window corrected with the FlowDirection property + /// + AnchorStyle CorrectedAnchor + { + get + { + if (Anchor == AnchorStyle.Left && FlowDirection == FlowDirection.RightToLeft) + return AnchorStyle.Right; + else if (Anchor == AnchorStyle.Right && FlowDirection == FlowDirection.RightToLeft) + return AnchorStyle.Left; + + return Anchor; + } + } + + /// + /// Refrenced pane + /// + FlyoutDockablePane _refPane; + + /// + /// Gets the pane that is hosted in flyout window + /// + internal FlyoutDockablePane ReferencedPane + { + get { return _refPane; } + } + + /// + /// Initialize the window + /// + /// + protected override void OnInitialized(EventArgs e) + { + base.OnInitialized(e); + + //Attach the referenced pane to show + if (ReferencedPane == null) + _refPane = this.Content as FlyoutDockablePane; + + if (ReferencedPane != null) + { + //move the pane under me as content + //ReferencePane now changes visual tree! + Content = ReferencedPane; + InitClosingTimer(); + } + } + + /// + /// Popup window that hosts the resizer thumb + /// + /// Resizer is host in a popup window becaus it needs to overlay winforms controls. + Window _resizerPopup = null; + + //public override void OnApplyTemplate() + //{ + // base.OnApplyTemplate(); + + // _resizerPopup = GetTemplateChild("INT_ResizerPopup") as Popup; + //} + + + #region Resize management + + Border _resizerGhost = null; + Window _resizerWindowHost = null; + Vector _initialStartPoint; + + void ShowResizerOverlayWindow(Resizer splitter) + { + _resizerGhost = new Border() + { + Background = Brushes.Black, + Opacity = 0.7 + }; + + if (CorrectedAnchor == AnchorStyle.Left || CorrectedAnchor == AnchorStyle.Right) + { + _resizerGhost.Width = splitter.Width; + _resizerGhost.Height = MaxHeight; + } + else + { + _resizerGhost.Height = splitter.Height; + _resizerGhost.Width = MaxWidth; + } + + Canvas panelHostResizer = new Canvas() + { + HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, + VerticalAlignment = System.Windows.VerticalAlignment.Stretch + }; + + panelHostResizer.Children.Add(_resizerGhost); + + _resizerWindowHost = new Window() + { + ResizeMode = ResizeMode.NoResize, + WindowStyle = System.Windows.WindowStyle.None, + ShowInTaskbar = false, + AllowsTransparency = true, + Background = null, + Width = MaxWidth, + Height = MaxHeight, + Left = Left, + Top = Top, + ShowActivated = false, + Owner = this, + Content = panelHostResizer + }; + + if (CorrectedAnchor == AnchorStyle.Right) + _resizerWindowHost.Left = Left - MaxWidth + Width; + else if (CorrectedAnchor == AnchorStyle.Bottom) + _resizerWindowHost.Top = Top - MaxHeight + Height; + + if (CorrectedAnchor == AnchorStyle.Left) + { + Canvas.SetLeft(_resizerGhost, Width - splitter.Width); + } + else if (CorrectedAnchor == AnchorStyle.Right) + { + Canvas.SetLeft(_resizerGhost, MaxWidth - Width); + } + else if (CorrectedAnchor == AnchorStyle.Top) + { + Canvas.SetTop(_resizerGhost, Height - splitter.Height); + } + else if (CorrectedAnchor == AnchorStyle.Bottom) + { + Canvas.SetTop(_resizerGhost, MaxHeight - Height); + } + + _initialStartPoint = new Vector(Canvas.GetLeft(_resizerGhost), Canvas.GetTop(_resizerGhost)); + + _resizerWindowHost.Show(); + } + + void HideResizerOverlayWindow() + { + if (_resizerWindowHost != null) + { + _resizerWindowHost.Close(); + _resizerWindowHost = null; + } + } + + + //void ShowResizerPopup() + //{ + // _resizerPopup = new Window() + // { + // AllowsTransparency = true, + // Background = Brushes.Transparent, + // ShowActivated = false, + // ShowInTaskbar = false, + // ResizeMode = System.Windows.ResizeMode.NoResize, + // WindowStyle = System.Windows.WindowStyle.None, + // Owner = this + // }; + + // Debug.WriteLine(string.Format("{0}-{1} {2}-{3}", + // Left, + // Top, + // Width, + // Height)); + + // Canvas resizerCanvas = new Canvas() { Width = MaxWidth, Height = MaxHeight, Background = null}; + // Border resizer = new Border() { Background = new SolidColorBrush(Colors.DarkGray), Opacity = 0.1 }; + + // switch (CorrectedAnchor) + // { + // case AnchorStyle.Left: + // { + // _resizerPopup.Left = Left; + // _resizerPopup.Top = Top; + // _resizerPopup.Width = MaxWidth; + // _resizerPopup.Height = MaxHeight; + + // resizer.Width = 4; + // resizer.Height = MaxHeight; + // resizer.Cursor = Cursors.SizeWE; + + // Canvas.SetLeft(resizer, Width - resizer.Width); + // Canvas.SetTop(resizer, 0.0); + // } + // break; + // case AnchorStyle.Right: + // { + // _resizerPopup.Left = Left - MaxWidth + Width; + // _resizerPopup.Top = Top; + // _resizerPopup.Width = MaxWidth; + // _resizerPopup.Height = MaxHeight; + + // resizer.Width = 4; + // resizer.Height = MaxHeight; + // resizer.Cursor = Cursors.SizeWE; + + // Canvas.SetLeft(resizer, MaxWidth - Width); + // Canvas.SetTop(resizer, 0.0); + // } + // break; + // case AnchorStyle.Top: + // { + // _resizerPopup.Left = Left; + // _resizerPopup.Top = Top; + // _resizerPopup.Width = MaxWidth; + // _resizerPopup.Height = MaxHeight; + + // resizer.Width = MaxWidth; + // resizer.Height = 4; + // resizer.Cursor = Cursors.SizeNS; + + // Canvas.SetLeft(resizer, 4); + // Canvas.SetTop(resizer, Height - resizer.Height); + // } + // break; + // case AnchorStyle.Bottom: + // { + // _resizerPopup.Left = Left; + // _resizerPopup.Top = Top - MaxHeight + Height; + // _resizerPopup.Width = MaxWidth; + // _resizerPopup.Height = MaxHeight; + + // resizer.Width = MaxWidth; + // resizer.Height = 4; + // resizer.Cursor = Cursors.SizeNS; + + // Canvas.SetLeft(resizer, 4); + // Canvas.SetTop(resizer, MaxHeight - Height); + // } + // break; + // } + + // resizerCanvas.Children.Add(resizer); + + + // _resizerPopup.Content = resizerCanvas; + // _resizerPopup.Show(); + //} + + //void HideResizerPopup() + //{ + // if (_resizerPopup == null) + // return; + + // //_resizerPopup.IsOpen = false; + // _resizerPopup.Close(); + // _resizerPopup = null; + //} + + //void UpdateResizerPopup() + //{ + // if (_resizerPopup == null) + // return; + + // switch (CorrectedAnchor) + // { + // case AnchorStyle.Left: + // { + // //_resizerPopup.PlacementRectangle = new Rect(Left, Top, MaxWidth, MaxHeight); + // _resizerPopup.Left = Left; + // _resizerPopup.Top = Top; + // _resizerPopup.Width = MaxWidth; + // _resizerPopup.Height = MaxHeight; + + // } + // break; + // case AnchorStyle.Right: + // { + // //_resizerPopup.PlacementRectangle = new Rect(Left - MaxWidth + Width, Top, MaxWidth, MaxHeight); + // } + // break; + // } + + //} + + /// + /// Gets a value indicating if user is resizer the window + /// + public bool IsResizing { get; private set; } + + #endregion + + #region Closing window strategies + + + DispatcherTimer _closingTimer = null; + + ///// + ///// Start the closing timer + ///// + //void StartClosingTimer() + //{ + // //if (_closingTimer != null) + // // _closingTimer.Start(); + //} + + /// + /// Creates the closing timer + /// + void InitClosingTimer() + { + if (_closingTimer == null) + { + _closingTimer = new DispatcherTimer( + new TimeSpan(0, 0, 1), + DispatcherPriority.Background, + new EventHandler(ForceCloseWindow), + Dispatcher.CurrentDispatcher); + _closingTimer.Start(); + } + } + + /// + /// Stop the closing timer + /// + void StopClosingTimer() + { + if (_closingTimer != null) + { + _closingTimer.Stop(); + _closingTimer = null; + } + } + + ///// + ///// Stop the closing timer + ///// + //void StopClosingTimer() + //{ + // //if (_closingTimer != null) + // // _closingTimer.Stop(); + //} + + /// + /// This handler is called when the closing time delay is elapsed (user is focusing to something else of the UI) + /// + /// + /// + void ForceCloseWindow(object sender, EventArgs e) + { + //Debug.WriteLine(string.Format("IsMouseOver={0}", IsMouseOverPane)); + //Debug.WriteLine(string.Format("IsFocused={0}", _winFormsHost != null && _winFormsHost.IsFocused)); + + //options menu is open don't close the flyout window + if (ReferencedPane.IsOptionsMenuOpen || + IsMouseOverPane || + (_winFormsHost != null && _winFormsHost.IsFocused && _refPane.Items.Count > 0 && ((ManagedContent)_refPane.Items[0]).IsActiveContent) || + IsActive || + _refPane.IsKeyboardFocusWithin || + _refPane.ContainsActiveContent || + (AnchorTabActivating != null && AnchorTabActivating.IsMouseOver) || + IsResizing || + (_resizerPopup != null && _resizerPopup.IsMouseOver)) + { + return; + } + + StopClosingTimer(); + + if (IsClosed) + return; + + ClosePane(); + } + + bool IsMouseOverPane + { + get + { + InteropHelper.Win32Point pt = new InteropHelper.Win32Point(); + if (!InteropHelper.GetCursorPos(ref pt)) + return false; + + Point ptMouse = PointToScreen(new Point()); + //Debug.WriteLine(string.Format("{0}-{1}", pt.X, pt.Y)); + + Rect rectWindow = new Rect(ptMouse.X, ptMouse.Y, Width, Height); + return rectWindow.Contains(new Point(pt.X,pt.Y)); + } + } + + + //protected override void OnMouseLeave(MouseEventArgs e) + //{ + // base.OnMouseLeave(e); + + // if (!IsFocused && !IsKeyboardFocusWithin && !ReferencedPane.IsOptionsMenuOpen) + // StartClosingTimer(); + //} + + //protected override void OnMouseMove(MouseEventArgs e) + //{ + // base.OnMouseMove(e); + + // StopClosingTimer(); + //} + + //protected override void OnLostFocus(RoutedEventArgs e) + //{ + // base.OnLostFocus(e); + + // if (!IsMouseOver && !ReferencedPane.IsOptionsMenuOpen) + // StartClosingTimer(); + //} + + //protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) + //{ + // base.OnLostKeyboardFocus(e); + + // if (!IsMouseOver) + // StopClosingTimer(); + //} + + //protected override void OnGotFocus(RoutedEventArgs e) + //{ + // base.OnGotFocus(e); + + // StopClosingTimer(); + //} + + //protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) + //{ + // base.OnGotKeyboardFocus(e); + + // StopClosingTimer(); + //} + + //internal void KeepWindowOpen() + //{ + // StopClosingTimer(); + //} + #endregion + + #region Open/Close Flyout window + + /// + /// Gets a value indicating if the flyout window is closing + /// + public bool IsClosing { get; private set; } + + /// + /// Initiate a closing animation + /// + void CloseWidthAnimation() + { + AnchorStyle CorrectedAnchor = Anchor; + + if (CorrectedAnchor == AnchorStyle.Left && FlowDirection == FlowDirection.RightToLeft) + CorrectedAnchor = AnchorStyle.Right; + else if (CorrectedAnchor == AnchorStyle.Right && FlowDirection == FlowDirection.RightToLeft) + CorrectedAnchor = AnchorStyle.Left; + + double wnd_Width = this.ActualWidth; + double wnd_Height = this.ActualHeight; + double wnd_Left = this.Left; + double wnd_Top = this.Top; + + int wnd_TrimWidth = (int)wnd_Width; + int wnd_TrimHeight = (int)wnd_Height; + + int stepWidth = (int)(wnd_Width / 4); + int stepHeight = (int)(wnd_Height / 4); + + DispatcherTimer animTimer = new DispatcherTimer(); + animTimer.Interval = TimeSpan.FromMilliseconds(1); + + animTimer.Tick += (sender, eventArgs) => + { + bool stopTimer = false; + double newLeft = 0.0; + double newTop = 0.0; + switch (CorrectedAnchor) + { + case AnchorStyle.Right: + newLeft = this.Left; + if (this.Left + stepWidth >= wnd_Left + wnd_Width) + { + newLeft = wnd_Left + wnd_Width; + wnd_TrimWidth = 0; + stopTimer = true; + } + else + { + newLeft += stepWidth; + wnd_TrimWidth -= stepWidth; + wnd_TrimWidth = Math.Max(wnd_TrimWidth, 0); + } + + //SetWindowRgn(new WindowInteropHelper(this).Handle, CreateRectRgn(0, 0, wnd_TrimWidth, wnd_TrimHeight), true); + ApplyRegion(new Rect(0, 0, wnd_TrimWidth, wnd_TrimHeight)); + this.Left = newLeft; + break; + case AnchorStyle.Left: + newLeft = this.Left; + if (this.Left - stepWidth <= wnd_Left - wnd_Width) + { + newLeft = wnd_Left - wnd_Width; + wnd_TrimWidth = 0; + stopTimer = true; + } + else + { + newLeft -= stepWidth; + wnd_TrimWidth -= stepWidth; + wnd_TrimWidth = Math.Max(wnd_TrimWidth, 0); + } + + this.Left = newLeft; + //SetWindowRgn(new WindowInteropHelper(this).Handle, CreateRectRgn((int)(wnd_Left - this.Left), 0, (int)(wnd_Width), wnd_TrimHeight), true); + ApplyRegion( + new Rect((int)(wnd_Left - this.Left), 0, (int)(wnd_Width), wnd_TrimHeight)); + break; + case AnchorStyle.Bottom: + newTop = this.Top; + if (this.Top + stepHeight >= wnd_Top + wnd_Height) + { + newTop = wnd_Top + wnd_Height; + wnd_TrimHeight = 0; + stopTimer = true; + } + else + { + newTop += stepHeight; + wnd_TrimHeight -= stepHeight; + wnd_TrimHeight = Math.Max(wnd_TrimHeight, 0); + } + + //SetWindowRgn(new WindowInteropHelper(this).Handle, CreateRectRgn(0, 0, wnd_TrimWidth, wnd_TrimHeight), true); + ApplyRegion( + new Rect(0, 0, wnd_TrimWidth, wnd_TrimHeight)); + this.Top = newTop; + break; + case AnchorStyle.Top: + newTop = this.Top; + if (this.Top - stepHeight <= wnd_Top - wnd_Height) + { + newTop = wnd_Top - wnd_Height; + wnd_TrimHeight = 0; + stopTimer = true; + } + else + { + newTop -= stepHeight; + wnd_TrimHeight -= stepHeight; + wnd_TrimHeight = Math.Max(wnd_TrimWidth, 0); + } + + this.Top = newTop; + ApplyRegion( + new Rect(0, (int)(wnd_Top - this.Top), wnd_TrimWidth, (int)(wnd_Height))); + //SetWindowRgn(new WindowInteropHelper(this).Handle, CreateRectRgn(0, (int)(wnd_Top - this.Top), wnd_TrimWidth, (int)(wnd_Height)), true); + break; + } + + if (stopTimer) + { + //window is being closed + Width = 0.0; + Height = 0.0; + animTimer.Stop(); + if (!IsClosed) + ClosePane(); + IsClosing = false; + } + }; + + IsClosing = true; + animTimer.Start(); + } + + /// + /// Gets a flag indicating if flyout window is opening + /// + public bool IsOpening { get; private set; } + + /// + /// Initiate an opening animation + /// + void OpenWidthAnimation() + { + double wnd_Width = this._targetWidth > 0.0 ? this._targetWidth : this.ActualWidth; + double wnd_Height = this._targetHeight > 0.0 ? this._targetHeight : this.ActualHeight; + double wnd_Left = this.Left; + double wnd_Top = this.Top; + + int wnd_TrimWidth = 0; + int wnd_TrimHeight = 0; + + int stepWidth = (int)(wnd_Width / 4); + int stepHeight = (int)(wnd_Height / 4); + + if (CorrectedAnchor == AnchorStyle.Left) + { + InteropHelper.SetWindowRgn(new WindowInteropHelper(this).Handle, InteropHelper.CreateRectRgn(0, 0, 0, (int)wnd_Height - wnd_TrimHeight), true); + this.Left = wnd_Left - wnd_Width; + } + else if (CorrectedAnchor == AnchorStyle.Top) + { + InteropHelper.SetWindowRgn(new WindowInteropHelper(this).Handle, InteropHelper.CreateRectRgn(0, 0, (int)wnd_Width - wnd_TrimWidth, 0), true); + this.Top = wnd_Top - wnd_Height; + } + + DispatcherTimer animTimer = new DispatcherTimer(); + animTimer.Interval = TimeSpan.FromMilliseconds(1); + + animTimer.Tick += (sender, eventArgs) => + { + bool stopTimer = false; + switch (CorrectedAnchor) + { + case AnchorStyle.Right: + { + double newLeft = this.Left; + if (this.Left - stepWidth <= wnd_Left - wnd_Width) + { + newLeft = wnd_Left - wnd_Width; + wnd_TrimWidth = (int)wnd_Width; + stopTimer = true; + } + else + { + newLeft -= stepWidth; + wnd_TrimWidth += stepWidth; + } + + Width = _targetWidth; + this.Left = newLeft; + ApplyRegion(new Rect(0, 0, wnd_TrimWidth, (int)wnd_Height - wnd_TrimHeight)); + } + break; + case AnchorStyle.Left: + { + double newLeft = this.Left; + if (this.Left + stepWidth >= wnd_Left) + { + newLeft = wnd_Left; + wnd_TrimWidth = (int)wnd_Width; + stopTimer = true; + } + else + { + newLeft += stepWidth; + wnd_TrimWidth += stepWidth; + } + + ApplyRegion( + new Rect((int)(wnd_Left - this.Left), 0, (int)(wnd_Width), (int)wnd_Height - wnd_TrimHeight)); + + Width = _targetWidth; + this.Left = newLeft; + } + break; + case AnchorStyle.Bottom: + { + double newTop = this.Top; + if (this.Top - stepHeight <= wnd_Top - wnd_Height) + { + newTop = wnd_Top - wnd_Height; + wnd_TrimHeight = (int)wnd_Height; + stopTimer = true; + } + else + { + newTop -= stepHeight; + wnd_TrimHeight += stepHeight; + } + + ApplyRegion( + new Rect(0, 0, (int)wnd_Width - wnd_TrimWidth, wnd_TrimHeight)); + + Height = _targetHeight; + this.Top = newTop; + + } + break; + case AnchorStyle.Top: + { + double newTop = this.Top; + if (this.Top + stepHeight >= wnd_Top) + { + newTop = wnd_Top; + wnd_TrimHeight = (int)wnd_Height; + stopTimer = true; + } + else + { + newTop += stepHeight; + wnd_TrimHeight += stepHeight; + } + + ApplyRegion( + new Rect(0, (int)(wnd_Top - this.Top), (int)wnd_Width - wnd_TrimWidth, (int)(wnd_Height))); + + Height = _targetHeight; + this.Top = newTop; + } + break; + } + + if (stopTimer) + { + UpdatePositionAndSize(); + animTimer.Stop(); + IsOpening = false; + } + }; + + IsOpening = true; + animTimer.Start(); + } + + /// + /// Open the flyout window with or without animation depending on the ShowAnimated flag + /// + void OpenPane() + { + if (_dockingManager.IsAnimationEnabled) + { + OpenWidthAnimation(); + } + else + { + switch (CorrectedAnchor) + { + case AnchorStyle.Left: + Width = this._targetWidth; + break; + case AnchorStyle.Right: + Width = this._targetWidth; + Left -= this.Width; + break; + case AnchorStyle.Top: + Height = this._targetHeight; + break; + case AnchorStyle.Bottom: + Height = this._targetHeight; + Top -= this.Height; + break; + } + + UpdatePositionAndSize(); + //ShowResizerPopup(); + //StartClosingTimer(); + } + } + + + /// + /// Close the flyout window with or without animation depending on the ShowAnimated flag + /// + void ClosePane() + { + if (_dockingManager.IsAnimationEnabled) + { + CloseWidthAnimation(); + } + else + { + if (!IsClosed) + Close(); + } + } + #endregion + + + #region Clipping Region + + protected override void OnActivated(EventArgs e) + { + if (!IsOpening && !IsClosing) + UpdatePositionAndSize(); + + base.OnActivated(e); + } + + //protected override void OnDeactivated(EventArgs e) + //{ + // //StartClosingTimer(); + // base.OnDeactivated(e); + //} + + internal void UpdatePositionAndSize() + { + ApplyRegion(new Rect(0, 0, Width, Height)); + } + + Rect _lastApplyRect = Rect.Empty; + + void ApplyRegion(Rect wndRect) + { + if (!this.CanTransform()) + return; + + wndRect = new Rect( + this.TransformFromDeviceDPI(wndRect.TopLeft), + this.TransformFromDeviceDPI(wndRect.Size)); + + _lastApplyRect = wndRect; + + if (PresentationSource.FromVisual(this) == null) + return; + + + if (_dockingManager != null) + { + List otherRects = new List(); + + foreach (Window fl in Window.GetWindow(_dockingManager).OwnedWindows) + { + //not with myself! + if (fl == this) + continue; + + if (!fl.IsVisible) + continue; + + Rect flRect = new Rect( + PointFromScreen(new Point(fl.Left, fl.Top)), + PointFromScreen(new Point(fl.Left + fl.Width, fl.Top + fl.Height))); + + if (flRect.IntersectsWith(wndRect)) + otherRects.Add(Rect.Intersect(flRect, wndRect)); + } + + IntPtr hDestRegn = InteropHelper.CreateRectRgn( + (int)wndRect.Left, + (int)wndRect.Top, + (int)wndRect.Right, + (int)wndRect.Bottom); + + foreach (Rect otherRect in otherRects) + { + IntPtr otherWin32Rect = InteropHelper.CreateRectRgn( + (int)otherRect.Left, + (int)otherRect.Top, + (int)otherRect.Right, + (int)otherRect.Bottom); + + InteropHelper.CombineRgn(hDestRegn, hDestRegn, otherWin32Rect, (int)InteropHelper.CombineRgnStyles.RGN_DIFF); + } + + + InteropHelper.SetWindowRgn(new WindowInteropHelper(this).Handle, hDestRegn, true); + } + } + #endregion + } +} diff --git a/src/Libraries/AvalonDock/GreyableImage/GreyableImage.cs b/src/Libraries/AvalonDock/AvalonDock/GreyableImage.cs similarity index 100% rename from src/Libraries/AvalonDock/GreyableImage/GreyableImage.cs rename to src/Libraries/AvalonDock/AvalonDock/GreyableImage.cs diff --git a/src/Libraries/AvalonDock/HelperFunc.cs b/src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs similarity index 88% rename from src/Libraries/AvalonDock/HelperFunc.cs rename to src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs index 3d8373bb48..aab9b12344 100644 --- a/src/Libraries/AvalonDock/HelperFunc.cs +++ b/src/Libraries/AvalonDock/AvalonDock/HelperFunc.cs @@ -11,13 +11,12 @@ namespace AvalonDock { internal static class HelperFunc { - //public static bool AreVeryClose(double v1, double v2) - //{ - // if (Math.Abs(v1 - v2) < 0.000001) - // return true; - - // return false; - //} + public static void ForEach(this IEnumerable collection, Action action) + { + foreach (T v in collection) + action(v); + } + public static bool AreClose(double v1, double v2) { if (v1 == v2) @@ -132,28 +131,27 @@ namespace AvalonDock return null; } - public static DockablePane FindChildDockablePane(this DockingManager manager, AnchorStyle desideredAnchor) + public static IEnumerable DockablePanes(this UIElement element) { - foreach (UIElement childObject in LogicalTreeHelper.GetChildren(manager)) + if (element is DockablePane) + yield return element as DockablePane; + + foreach (UIElement childObject in LogicalTreeHelper.GetChildren(element)) { - DockablePane foundPane = FindChildDockablePane(childObject, desideredAnchor); - if (foundPane != null) - return foundPane; - } + if (element is DockablePane) + yield return element as DockablePane; - return null; + yield return FindChildDockablePane(childObject); + } } - static DockablePane FindChildDockablePane(UIElement parent, AnchorStyle desideredAnchor) + static DockablePane FindChildDockablePane(UIElement parent) { - if (parent is DockablePane && ((DockablePane)parent).Anchor == desideredAnchor) - return parent as DockablePane; - if (parent is ResizingPanel) { foreach (UIElement childObject in ((ResizingPanel)parent).Children) { - DockablePane foundPane = FindChildDockablePane(childObject, desideredAnchor); + DockablePane foundPane = FindChildDockablePane(childObject); if (foundPane != null) return foundPane; } diff --git a/src/Libraries/AvalonDock/IDockableControl.cs b/src/Libraries/AvalonDock/AvalonDock/IDockableControl.cs similarity index 97% rename from src/Libraries/AvalonDock/IDockableControl.cs rename to src/Libraries/AvalonDock/AvalonDock/IDockableControl.cs index 428fc143fb..e7dae9b412 100644 --- a/src/Libraries/AvalonDock/IDockableControl.cs +++ b/src/Libraries/AvalonDock/AvalonDock/IDockableControl.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, diff --git a/src/Libraries/AvalonDock/IDropSurface.cs b/src/Libraries/AvalonDock/AvalonDock/IDropSurface.cs similarity index 97% rename from src/Libraries/AvalonDock/IDropSurface.cs rename to src/Libraries/AvalonDock/AvalonDock/IDropSurface.cs index c6ce35139e..8738035716 100644 --- a/src/Libraries/AvalonDock/IDropSurface.cs +++ b/src/Libraries/AvalonDock/AvalonDock/IDropSurface.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -33,7 +33,7 @@ namespace AvalonDock /// /// Defines an interface that must be implemented by objects that can host dragged panes /// - interface IDropSurface + internal interface IDropSurface { /// /// Gets a value indicating if this area is avilable for drop a dockable pane diff --git a/src/Libraries/AvalonDock/AvalonDock/InteropHelper.cs b/src/Libraries/AvalonDock/AvalonDock/InteropHelper.cs new file mode 100644 index 0000000000..5fa361acb1 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/InteropHelper.cs @@ -0,0 +1,71 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; + +namespace AvalonDock +{ + internal sealed class InteropHelper + { + [DllImport("user32.dll")] + public static extern int SetWindowRgn(IntPtr hWnd, IntPtr hRgn, bool bRedraw); + + [DllImport("gdi32.dll")] + public static extern IntPtr CreateRectRgn(int left, int top, int right, int bottom); + + [DllImport("gdi32.dll")] + public static extern int CombineRgn(IntPtr hrgnDest, IntPtr hrgnSrc1, IntPtr hrgnSrc2, int fnCombineMode); + + public enum CombineRgnStyles : int + { + RGN_AND = 1, + RGN_OR = 2, + RGN_XOR = 3, + RGN_DIFF = 4, + RGN_COPY = 5, + RGN_MIN = RGN_AND, + RGN_MAX = RGN_COPY + } + + + [StructLayout(LayoutKind.Sequential)] + internal struct Win32Point + { + public Int32 X; + public Int32 Y; + }; + + [DllImport("user32.dll")] + internal static extern bool GetCursorPos(ref Win32Point pt); + + + + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/LogicalTreeAdapter.cs b/src/Libraries/AvalonDock/AvalonDock/LogicalTreeAdapter.cs new file mode 100644 index 0000000000..ae3d25ed72 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/LogicalTreeAdapter.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Media; +using System.Collections; + +namespace AvalonDock +{ + /// + /// Defines an adapter that must be implemented in order to use the LinqToTree + /// extension methods + /// + /// + internal interface ILinqToTree + { + /// + /// Obtains all the children of the Item. + /// + /// + IEnumerable> Children(); + + /// + /// The parent of the Item. + /// + ILinqToTree Parent { get; } + + /// + /// The item being adapted. + /// + T Item { get; } + } + + internal static class ILinqToTreeExts + { + /// + /// Returns a collection of descendant elements. + /// + public static IEnumerable> + Descendants(this ILinqToTree adapter) + { + foreach (var child in adapter.Children()) + { + yield return child; + + foreach (var grandChild in child.Descendants()) + { + yield return grandChild; + } + } + } + + /// + /// Returns a collection of ancestor elements. + /// + public static IEnumerable> + Ancestors(this ILinqToTree adapter) + { + var parent = adapter.Parent; + while (parent != null) + { + yield return parent; + parent = parent.Parent; + } + } + + /// + /// Returns a collection of child elements. + /// + public static IEnumerable> + Elements(this ILinqToTree adapter) + { + foreach (var child in adapter.Children()) + { + yield return child; + } + } + } + + /// + /// An adapter for DependencyObject which implements ILinqToTree in + /// order to allow Linq queries on the visual tree + /// + internal class VisualTreeAdapter : ILinqToTree + { + private DependencyObject _item; + + public VisualTreeAdapter(DependencyObject item) + { + _item = item; + } + + public IEnumerable> Children() + { + int childrenCount = VisualTreeHelper.GetChildrenCount(_item); + for (int i = 0; i < childrenCount; i++) + { + yield return new VisualTreeAdapter(VisualTreeHelper.GetChild(_item, i)); + } + } + + public ILinqToTree Parent + { + get + { + return new VisualTreeAdapter(VisualTreeHelper.GetParent(_item)); + } + } + + public DependencyObject Item + { + get + { + return _item; + } + } + } + + /// + /// An adapter for DependencyObject which implements ILinqToTree in + /// order to allow Linq queries on the logical tree + /// + internal class LogicalTreeAdapter : ILinqToTree + { + private DependencyObject _item; + + public LogicalTreeAdapter(DependencyObject item) + { + _item = item; + } + + public IEnumerable> Children() + { + IEnumerable children = LogicalTreeHelper.GetChildren(_item).OfType(); + foreach (DependencyObject child in children) + { + yield return new LogicalTreeAdapter(child); + } + } + + public ILinqToTree Parent + { + get + { + return new VisualTreeAdapter(LogicalTreeHelper.GetParent(_item)); + } + } + + public DependencyObject Item + { + get + { + return _item; + } + } + } + +} diff --git a/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs b/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs new file mode 100644 index 0000000000..c00b925e23 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/ManagedContent.cs @@ -0,0 +1,961 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Controls.Primitives; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Xml; +using System.Windows.Forms.Integration; +using System.Diagnostics; +using System.Windows.Threading; +using System.Threading; +using System.Reflection; +using System.Net.Cache; + + +namespace AvalonDock +{ + + public abstract class ManagedContent : ContentControl, INotifyPropertyChanged + { + static ManagedContent() + { + //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. + //This style is defined in themes\generic.xaml + DefaultStyleKeyProperty.OverrideMetadata(typeof(ManagedContent), new FrameworkPropertyMetadata(typeof(ManagedContent))); + + WidthProperty.OverrideMetadata(typeof(ManagedContent), new FrameworkPropertyMetadata(double.NaN, null, new CoerceValueCallback( + (s, v) => + { + if (!DesignerProperties.GetIsInDesignMode(s as DependencyObject)) + return double.NaN; + + return v; + }))); + HeightProperty.OverrideMetadata(typeof(ManagedContent), new FrameworkPropertyMetadata(double.NaN, null, new CoerceValueCallback( + (s, v) => + { + if (!DesignerProperties.GetIsInDesignMode(s as DependencyObject)) + return double.NaN; + + return v; + }))); + + FocusableProperty.OverrideMetadata(typeof(ManagedContent), new FrameworkPropertyMetadata(true)); + } + + public ManagedContent() + { + this.Loaded += new RoutedEventHandler(ManagedContent_Loaded); + this.Unloaded += new RoutedEventHandler(ManagedContent_Unloaded); + } + + //WindowsFormsHost GetWinFormsHost() + //{ + // WindowsFormsHost contentHost = null; + + // if (this.Content is UserControl) + // { + // UserControl usTemp = this.Content as UserControl; + + // if (usTemp.Content is WindowsFormsHost) + // contentHost = usTemp.Content as WindowsFormsHost; + // } + // else if (this.Content is WindowsFormsHost) + // { + // contentHost = this.Content as WindowsFormsHost; + // } + + // return contentHost; + //} + + void ManagedContent_SizeChanged(object sender, SizeChangedEventArgs e) + { + //WindowsFormsHost contentHost = GetWinFormsHost(); + + //if (contentHost != null) + //{ + // object childCtrl = contentHost.GetType().GetProperty("Child").GetValue(contentHost, null); + + // if (childCtrl != null) + // { + // this.Dispatcher.Invoke(new Action((o) => o.CallMethod("Refresh", null)), DispatcherPriority.Render, childCtrl); + // } + //} + } + + protected virtual void OnContentLoaded() + { + RaisePropertyChanged("ContainerPane"); + } + + protected virtual void OnContentUnloaded() + { + RaisePropertyChanged("ContainerPane"); + } + + void ManagedContent_Loaded(object sender, RoutedEventArgs e) + { + OnContentLoaded(); + + //WindowsFormsHost contentHost = GetWinFormsHost(); + + //if (contentHost != null) + //{ + // contentHost.SizeChanged += new SizeChangedEventHandler(ManagedContent_SizeChanged); + //} + } + + void ManagedContent_Unloaded(object sender, RoutedEventArgs e) + { + OnContentUnloaded(); + + //WindowsFormsHost contentHost = GetWinFormsHost(); + + //if (contentHost != null) + //{ + // contentHost.SizeChanged -= new SizeChangedEventHandler(ManagedContent_SizeChanged); + //} + } + + #region Title + + /// + /// Gets or set the title of the content + /// + public string Title + { + get { return (string)GetValue(TitleProperty); } + set { SetValue(TitleProperty, value); } + } + + // Using a DependencyProperty as the backing store for Title. This enables animation, styling, binding, etc... + public static readonly DependencyProperty TitleProperty = + DependencyProperty.Register("Title", typeof(string), typeof(ManagedContent)); + + #endregion + + #region Icon + + /// + /// Access to dependency property + /// + public ImageSource Icon + { + get { return (ImageSource)GetValue(IconProperty); } + set { SetValue(IconProperty, value); } + } + + /// + /// Select an icon object for the content + /// + public static readonly DependencyProperty IconProperty = + DependencyProperty.Register("Icon", typeof(ImageSource), typeof(ManagedContent), + new FrameworkPropertyMetadata(null, new CoerceValueCallback(OnCoerce_Icon))); + + private static object OnCoerce_Icon(DependencyObject o, object value) + { + //if (value is string) + //{ + // Uri iconUri; + // //// try to resolve given value as an absolute URI + // if (Uri.TryCreate(value as String, UriKind.Relative, out iconUri)) + // { + // ImageSource img = new BitmapImage(iconUri); + // if (img != null) + // return img;//new Image() { Source = img }; + + // //GreyableImage seems to be not compatible with .net 4 + // //if (null != img) + // //{ + // // GreyableImage icon = (o as ManagedContent).Icon as GreyableImage; + // // if (null == icon) + // // icon = new GreyableImage(); + + // // icon.Source = img; + // // //icon.Stretch = Stretch.None; + // // //icon.SnapsToDevicePixels = true; + + // // return icon; + // //} + // } + //} + return value; + } + + #endregion + + #region DefaultElement + + /// + /// Access to + /// + public IInputElement DefaultElement + { + + get { return (IInputElement)GetValue(DefaultFocusedElementProperty); } + + set { SetValue(DefaultFocusedElementProperty, value); } + + } + + /// + /// Gets or sets an element which is focused by default when content is activated + /// + public static readonly DependencyProperty DefaultFocusedElementProperty = DependencyProperty.Register("DefaultElement", typeof(IInputElement), typeof(ManagedContent)); + + #endregion + + FrameworkElement _dragEnabledArea; + + /// + /// Gets the draggable area of the document + /// + protected FrameworkElement DragEnabledArea + { + get { return _dragEnabledArea; } + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _dragEnabledArea = GetTemplateChild("PART_DragArea") as FrameworkElement; + + if (_dragEnabledArea != null) + { + _dragEnabledArea.MouseDown += new MouseButtonEventHandler(OnDragMouseDown); + _dragEnabledArea.MouseMove += new MouseEventHandler(OnDragMouseMove); + _dragEnabledArea.MouseUp += new MouseButtonEventHandler(OnDragMouseUp); + _dragEnabledArea.MouseLeave += new MouseEventHandler(OnDragMouseLeave); + } + + if (_dragEnabledArea != null) + _dragEnabledArea.InputBindings.Add(new InputBinding(ManagedContentCommands.Close, new MouseGesture(MouseAction.MiddleClick))); + + } + + #region Mouse management + + protected virtual void OnDragStart(Point ptMouse, Point ptrelativeMouse) + { + + } + + Point ptStartDrag; + bool isMouseDown = false; + + protected Point StartDragPoint + { + get { return ptStartDrag; } + } + + protected bool IsMouseDown + { + get { return isMouseDown; } + } + + protected void ResetIsMouseDownFlag() + { + isMouseDown = false; + } + + protected virtual void OnDragMouseDown(object sender, MouseButtonEventArgs e) + { + if (!e.Handled && Manager != null)// && State != DockableContentState.AutoHide) + { + isMouseDown = true; + ptStartDrag = e.GetPosition((IInputElement)System.Windows.Media.VisualTreeHelper.GetParent(this)); + } + } + + protected virtual void OnDragMouseMove(object sender, MouseEventArgs e) + { + } + + protected virtual void OnDragMouseUp(object sender, MouseButtonEventArgs e) + { + isMouseDown = false; + } + + Point ptRelativePosition; + + protected virtual void OnDragMouseLeave(object sender, MouseEventArgs e) + { + if (!e.Handled && e.LeftButton == MouseButtonState.Pressed && Manager != null) + { + if (!IsMouseCaptured) + { + //Point ptMouseMove = e.GetPosition(this); + Point ptMouseMove = e.GetPosition((IInputElement)System.Windows.Media.VisualTreeHelper.GetParent(this)); + ManagedContent contentToSwap = null; + if (ContainerPane != null) + { + foreach (ManagedContent content in ContainerPane.Items) + { + if (content == this) + continue; + + HitTestResult res = VisualTreeHelper.HitTest(content, e.GetPosition(content)); + if (res != null) + { + contentToSwap = content; + break; + } + } + } + + if (contentToSwap != null) + { + Pane containerPane = ContainerPane; + int myIndex = containerPane.Items.IndexOf(this); + + ContainerPane.Items.RemoveAt(myIndex); + + int otherIndex = containerPane.Items.IndexOf(contentToSwap); + containerPane.Items.RemoveAt(otherIndex); + + containerPane.Items.Insert(otherIndex, this); + + containerPane.Items.Insert(myIndex, contentToSwap); + + containerPane.SelectedItem = this; + + e.Handled = false; + return; + } + else if (Math.Abs(ptMouseMove.X - StartDragPoint.X) > SystemParameters.MinimumHorizontalDragDistance || + Math.Abs(ptMouseMove.Y - StartDragPoint.Y) > SystemParameters.MinimumVerticalDragDistance) + { + ptRelativePosition = e.GetPosition(DragEnabledArea); + + ResetIsMouseDownFlag(); + OnDragStart(StartDragPoint, ptRelativePosition); + e.Handled = true; + } + } + } + + isMouseDown = false; + } + + + #endregion + + protected override void OnMouseDown(MouseButtonEventArgs e) + { + base.OnMouseDown(e); + + if (!e.Handled) + { + Activate(); + //FocusManager.SetFocusedElement(Content as DependencyObject, DefaultElement); + //IInputElement focusedElement = e.Source as IInputElement; + //if (focusedElement != null) Keyboard.Focus(focusedElement); + } + } + + protected override void OnKeyDown(KeyEventArgs e) + { + if (e.Key == Key.Enter) + { + if (ContainerPane != null) + ContainerPane.SelectedItem = this; + } + + base.OnKeyDown(e); + } + + /// + /// Gets container pane currently hosting the content + /// + /// Please note that this value could change as user move the content around the . + public Pane ContainerPane + { + get + { + Pane containerPane = Parent as Pane; + if (containerPane != null) + return containerPane; + + return this.FindVisualAncestor(false); + } + } + + /// + /// Remove this content from its parent container pane + /// + /// + internal virtual ManagedContent DetachFromContainerPane() + { + if (ContainerPane != null) + { + int indexOfContent = ContainerPane.Items.IndexOf(this); + return ContainerPane.RemoveContent(indexOfContent) as ManagedContent; + } + + return null; + } + + protected override void OnVisualParentChanged(DependencyObject oldParent) + { + RaisePropertyChanged("ContainerPane"); + base.OnVisualParentChanged(oldParent); + } + + #region Manager + + private DockingManager _manager = null; + + /// + /// Get current hosting docking manager () + /// + public DockingManager Manager + { + get { return _manager; } + internal set + { + if (_manager != value) + { + DockingManager oldValue = _manager; + _manager = value; + OnManagerChanged(oldValue, value); + RaisePropertyChanged("Manager"); + } + } + } + + /// + /// Provides derived classes an opportunity to handle changes to the Manager property. + /// + protected virtual void OnManagerChanged(DockingManager oldValue, DockingManager newValue) + { + } + + #endregion + + protected DockingManager GetParentManager(Pane containerPane) + { + if (containerPane == null) + containerPane = ContainerPane; + + if (containerPane != null) + return ContainerPane.GetManager(); + + return null; + } + + protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e) + { + base.OnGotKeyboardFocus(e); + + Debug.WriteLine(string.Format("[{0}].OnGotKeyboardFocus() Source={1} NewFocus={2} OldFocus={3}", this.Name, e.Source.GetType().ToString(), e.NewFocus.GetType().ToString(), e.OldFocus == null ? "" : e.OldFocus.GetType().ToString())); + + if (Manager != null && + this.IsKeyboardFocusWithin) + { + Manager.ActiveContent = this; + } + } + + protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e) + { + Debug.WriteLine(string.Format("[{0}].OnLostKeyboardFocus() Source={1} NewFocus={2} OldFocus={3}", this.Name, e.Source.GetType().ToString(), e.NewFocus == null ? "" : e.NewFocus.GetType().ToString(), e.OldFocus == null ? "" : e.OldFocus.GetType().ToString())); + base.OnLostKeyboardFocus(e); + } + + #region IsActiveContent + + /// + /// IsActiveContent Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey IsActiveContentPropertyKey + = DependencyProperty.RegisterReadOnly("IsActiveContent", typeof(bool), typeof(ManagedContent), + new FrameworkPropertyMetadata((bool)false, + new PropertyChangedCallback(OnIsActiveContentChanged))); + + public static readonly DependencyProperty IsActiveContentProperty + = IsActiveContentPropertyKey.DependencyProperty; + + /// + /// Gets the IsActiveContent property. This dependency property + /// indicates the active (selected) content between all contents of the docking manager + /// + public bool IsActiveContent + { + get { return (bool)GetValue(IsActiveContentProperty); } + } + + /// + /// Provides a secure method for setting the IsActiveContent property. + /// This dependency property indicates the current content is the active content between all docking manager contents + /// + /// The new value for the property. + internal void SetIsActiveContent(bool value) + { + SetValue(IsActiveContentPropertyKey, value); + } + + + /// + /// Handles changes to the IsActiveContent property. + /// + private static void OnIsActiveContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((ManagedContent)d).OnIsActiveContentChanged(e); + } + + DateTime _lastActivation = DateTime.MinValue; + + internal DateTime LastActivation + { + get { return _lastActivation; } + } + + /// + /// Provides derived classes an opportunity to handle changes to the IsActiveContent property. + /// + protected virtual void OnIsActiveContentChanged(DependencyPropertyChangedEventArgs e) + { + if (IsActiveContent) + _lastActivation = DateTime.Now; + + FocusContent(); + + Pane parentPane = ContainerPane as Pane; + if (parentPane != null) + { + parentPane.RefreshContainsActiveContentProperty(); + if (IsActiveContent) + parentPane.SelectedItem = this; + } + + //for backward compatibility + RaisePropertyChanged("IsActiveContent"); + + if (IsActiveContentChanged != null) + IsActiveContentChanged(this, EventArgs.Empty); + } + + /// + /// Provides derived classes an opportunity to manage custom focus strategy. + /// + /// + /// Derived classes should not call base class if don't want AvalonDock to set focus on object + /// + protected virtual void FocusContent() + { + if (IsActiveContent && !IsKeyboardFocused) + { + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(delegate + { + if (IsActiveContent && !IsKeyboardFocused) + { + if (this.Content is WindowsFormsHost) + { + //Use reflection in order to remove WinForms assembly reference + WindowsFormsHost contentHost = this.Content as WindowsFormsHost; + + object childCtrl = contentHost.GetType().GetProperty("Child").GetValue(contentHost, null); + + if (childCtrl != null) + { + if (!childCtrl.GetPropertyValue("Focused")) + { + childCtrl.CallMethod("Focus", null); + } + } + } + else if (DefaultElement != null) + { + Debug.WriteLine("Try to set kb focus to " + DefaultElement); + + IInputElement kbFocused = Keyboard.Focus(DefaultElement); + + if (kbFocused != null) + Debug.WriteLine("Focused element " + kbFocused); + else + Debug.WriteLine("No focused element"); + + } + else if (this.Content is IInputElement) + { + Debug.WriteLine("Try to set kb focus to " + this.Content.ToString()); + IInputElement kbFocused = Keyboard.Focus(this.Content as IInputElement); + if (kbFocused != null) + Debug.WriteLine("Focused element " + kbFocused); + else + Debug.WriteLine("No focused element"); + } + } + })); + } + + + + } + + /// + /// Event fired when the property changes + /// + public event EventHandler IsActiveContentChanged; + #endregion + + #region IsActiveDocument + + /// + /// IsActiveDocument Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey IsActiveDocumentPropertyKey + = DependencyProperty.RegisterReadOnly("IsActiveDocument", typeof(bool), typeof(ManagedContent), + new FrameworkPropertyMetadata((bool)false, + new PropertyChangedCallback(OnIsActiveDocumentChanged))); + + public static readonly DependencyProperty IsActiveDocumentProperty + = IsActiveDocumentPropertyKey.DependencyProperty; + + /// + /// Gets the IsActiveDocument property. This dependency property + /// indicates is content is the active document. + /// + public bool IsActiveDocument + { + get { return (bool)GetValue(IsActiveDocumentProperty); } + } + + /// + /// Provides a secure method for setting the IsActiveDocument property. + /// This dependency property indicates is content is the active document. + /// + /// The new value for the property. + internal void SetIsActiveDocument(bool value) + { + SetValue(IsActiveDocumentPropertyKey, value); + } + + /// + /// Handles changes to the IsActiveDocument property. + /// + private static void OnIsActiveDocumentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((ManagedContent)d).OnIsActiveDocumentChanged(e); + } + + /// + /// Provides derived classes an opportunity to handle changes to the IsActiveDocument property. + /// + protected virtual void OnIsActiveDocumentChanged(DependencyPropertyChangedEventArgs e) + { + if ((bool)e.NewValue) + { + if (ContainerPane != null) + ContainerPane.SelectedItem = this; + } + + DocumentPane parentDocumentPane = ContainerPane as DocumentPane; + if (parentDocumentPane != null) + { + parentDocumentPane.RefreshContainsActiveDocumentProperty(); + } + + Debug.WriteLine("{0}-{1}-{2}", IsFocused, IsKeyboardFocused, IsKeyboardFocusWithin); + + //for backward compatibility + RaisePropertyChanged("IsActiveDocumentChanged"); + + if (IsActiveDocumentChanged != null) + IsActiveDocumentChanged(this, EventArgs.Empty); + } + + /// + /// Event fired when the property changes + /// + public event EventHandler IsActiveDocumentChanged; + + #endregion + + #region IsLocked + + /// + /// IsLocked Dependency Property + /// + public static readonly DependencyProperty IsLockedProperty = + DependencyProperty.Register("IsLocked", typeof(bool), typeof(ManagedContent), + new FrameworkPropertyMetadata((bool)false)); + + /// + /// Gets or sets the IsLocked property. This dependency property + /// indicates if this content is locked (for objects this often means that it's readonly). + /// + public bool IsLocked + { + get { return (bool)GetValue(IsLockedProperty); } + set { SetValue(IsLockedProperty, value); } + } + + #endregion + + #region FloatingWindowSize + + /// + /// FloatingWindowSize Dependency Property + /// + public static readonly DependencyProperty FloatingWindowSizeProperty = + DependencyProperty.Register("FloatingWindowSize", typeof(Size), typeof(ManagedContent), + new FrameworkPropertyMetadata(new Size(250,400), + new PropertyChangedCallback(OnFloatingWindowSizeChanged))); + + /// + /// Gets or sets the FloatingWindowSize property. This dependency property + /// indicates the size of the floating window hosting the content when it's floating. + /// + public Size FloatingWindowSize + { + get { return (Size)GetValue(FloatingWindowSizeProperty); } + set { SetValue(FloatingWindowSizeProperty, value); } + } + + /// + /// Handles changes to the FloatingWindowSize property. + /// + private static void OnFloatingWindowSizeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((ManagedContent)d).OnFloatingWindowSizeChanged(e); + } + + /// + /// Provides derived classes an opportunity to handle changes to the FloatingWindowSize property. + /// + protected virtual void OnFloatingWindowSizeChanged(DependencyPropertyChangedEventArgs e) + { + } + + #endregion + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + protected void RaisePropertyChanged(string propertyName) + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + #endregion + + #region IsCloseable + /// + /// Get or set a value indicating if this content can be closed or hidden + /// + public bool IsCloseable + { + get { return (bool)GetValue(IsCloseableProperty); } + set { SetValue(IsCloseableProperty, value); } + } + + // Using a DependencyProperty as the backing store for IsCloseable. This enables animation, styling, binding, etc... + public static readonly DependencyProperty IsCloseableProperty = + DependencyProperty.Register("IsCloseable", typeof(bool), typeof(ManagedContent), new UIPropertyMetadata(true)); + + internal virtual bool CanClose() + { + if (!IsCloseable) + return false; + + return true; + } + #endregion + + #region Commands + + protected override void OnInitialized(EventArgs e) + { + base.OnInitialized(e); + + this.CommandBindings.Add( + new CommandBinding(ManagedContentCommands.Hide, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(ManagedContentCommands.Close, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(ManagedContentCommands.Show, this.OnExecuteCommand, this.OnCanExecuteCommand)); + this.CommandBindings.Add( + new CommandBinding(ManagedContentCommands.Activate, this.OnExecuteCommand, this.OnCanExecuteCommand)); + + + } + + void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + { + if (e.Command == ManagedContentCommands.Show) + { + Show(); + e.Handled = true; + } + else if (e.Command == ManagedContentCommands.Hide) + { + e.Handled = Hide(); + } + else if (e.Command == ManagedContentCommands.Close) + { + e.Handled = Close(); + } + else if (e.Command == ManagedContentCommands.Activate) + { + Activate(); + e.Handled = true; + } + + //else if (e.Command == ShowOptionsCommand) + //{ + // OpenOptionsContextMenu(); + // e.Handled = true; + //} + + } + + + void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = CanExecuteCommand(e.Command); + + //Debug.WriteLine("ManagedContent.OnCanExecuteCommand({0}) = {1} (ContinueRouting={2})", (e.Command as RoutedUICommand).Name, e.CanExecute, e.ContinueRouting); + } + + + /// + /// Retrive a value indicating if the command passed can be executed based to the content state + /// + /// Command to execute + /// True if the command can be execute, false otherwise. + protected virtual bool CanExecuteCommand(ICommand command) + { + if (Manager == null) + return false; + + return true; + } + + /// + /// Shows the content + /// + /// How content is shows depends from the type of the content. + public abstract void Show(); + + /// + /// Shows the content inside a object + /// + /// How content is shows depends from the type of the content. + public abstract void Show(DockingManager manager); + + /// + /// Event fired when the content is about to be closed + /// + public event EventHandler Closing; + + /// + /// Event fired when the content has been closed + /// + /// Note that when a document is closed property like or returns null. + public event EventHandler Closed; + + /// + /// Ovveride this method to handle event. + /// + protected virtual void OnClosing(CancelEventArgs e) + { + if (Closing != null && !e.Cancel) + { + Closing(this, e); + } + } + + /// + /// Ovveride this method to handle event. + /// + protected virtual void OnClosed() + { + if (Closed != null) + Closed(this, EventArgs.Empty); + } + + /// + /// Close the content + /// + /// Returns true if the content was succesfully closed, false otherwise. + public abstract bool Close(); + + /// + /// Hide the content + /// + public abstract bool Hide(); + + /// + /// Set the content as the active content + /// + /// After this method returns property returns true. + public virtual void Activate() + { + if (ContainerPane != null && Manager != null)// && Manager.ActiveContent != this) + { + ContainerPane.SelectedItem = this; + ContainerPane.Focus(); + if (Manager != null) + Manager.ActiveContent = this; + } + } + #endregion + + #region Save/Restore Content Layout + /// + /// Save content specific layout settings + /// + /// Backend store writer + /// Custom derived class can overloads this method to handle custom layout persistence. + public virtual void SaveLayout(XmlWriter storeWriter) + { + } + + /// + /// Restore content specific layout settings + /// + /// Saved xml element containg content layout settings + /// Custom derived class must overload this method to restore custom layout settings previously saved trought . + public virtual void RestoreLayout(XmlElement contentElement) + { + } + #endregion + + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/ManagedContentCollection.cs b/src/Libraries/AvalonDock/AvalonDock/ManagedContentCollection.cs new file mode 100644 index 0000000000..c2766ff9c3 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/ManagedContentCollection.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Collections.ObjectModel; + +namespace AvalonDock +{ + public class ManagedContentCollection : ReadOnlyObservableCollection where T : ManagedContent + { + internal ManagedContentCollection(DockingManager manager) + : base(new ObservableCollection()) + { + Manager = manager; + } + + + /// + /// Get associated object + /// + public DockingManager Manager { get; private set; } + + /// + /// Override collection changed event to setup manager property on objects + /// + /// + protected override void OnCollectionChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + if (e.NewItems != null) + { + foreach (T cntAdded in e.NewItems) + cntAdded.Manager = Manager; + } + + base.OnCollectionChanged(e); + } + + /// + /// Add a content to the list + /// + /// + internal void Add(T contentToAdd) + { + if (!Items.Contains(contentToAdd)) + Items.Add(contentToAdd); + } + + internal void Remove(T contentToRemove) + { + Items.Remove(contentToRemove); + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/ManagedContentCommands.cs b/src/Libraries/AvalonDock/AvalonDock/ManagedContentCommands.cs new file mode 100644 index 0000000000..a1b39d4ce5 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/ManagedContentCommands.cs @@ -0,0 +1,126 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + /// + /// Defines commands shared beteween all contents (Dockable or Documents) + /// + public sealed class ManagedContentCommands + { + private static object syncRoot = new object(); + + + private static RoutedUICommand closeCommand = null; + + /// + /// This command closes the content + /// + public static RoutedUICommand Close + { + get + { + lock (syncRoot) + { + if (null == closeCommand) + { + closeCommand = new RoutedUICommand(AvalonDock.Properties.Resources.ManagedContentCommands_Close, "Close", typeof(ManagedContentCommands)); + } + } + return closeCommand; + } + } + + private static RoutedUICommand hideCommand = null; + + /// + /// This command hides the content + /// + public static RoutedUICommand Hide + { + get + { + lock (syncRoot) + { + if (null == hideCommand) + { + hideCommand = new RoutedUICommand(AvalonDock.Properties.Resources.ManagedContentCommands_Hide, "Hide", typeof(ManagedContentCommands)); + } + } + return hideCommand; + } + } + + private static RoutedUICommand showCommand = null; + + /// + /// This command shows the content + /// + /// How content is shown by default depends from the type of content. A is shown as docked pane, instead + /// a is shown as tabbed document + public static RoutedUICommand Show + { + get + { + lock (syncRoot) + { + if (null == showCommand) + { + showCommand = new RoutedUICommand(AvalonDock.Properties.Resources.ManagedContentCommands_Show, "Show", typeof(ManagedContentCommands)); + } + } + return showCommand; + } + } + + + private static RoutedUICommand activateCommand = null; + + /// + /// This command activate the commands (i.e. select it inside the conatiner pane) + /// + /// Activating a content means essentially putting it in evidence. For a content that is auto-hidden this command opens a flyout window containing the content. + public static RoutedUICommand Activate + { + get + { + lock (syncRoot) + { + if (null == activateCommand) + { + activateCommand = new RoutedUICommand(AvalonDock.Properties.Resources.ManagedContentCommands_Activate, "Activate", typeof(ManagedContentCommands)); + } + } + return activateCommand; + } + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs b/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs new file mode 100644 index 0000000000..1d9ee2d9c9 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/NavigatorWindow.cs @@ -0,0 +1,338 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.ComponentModel; +using System.Linq; +using System.Collections.ObjectModel; +using System.Diagnostics; + +namespace AvalonDock +{ + /// + /// Represent an navigator item within lists of contents that user can choose from the + /// + public class NavigatorWindowItem + { + private string _title; + + public string Title + { + get + { + return _title; + } + } + + private object _icon; + + public object Icon + { + get + { + return _icon; + } + } + + protected ManagedContent _content; + + public ManagedContent ItemContent + { + get { return _content; } + } + + internal NavigatorWindowItem(ManagedContent content) + { + _title = content.Title; + _icon = content.Icon; + _content = content; + } + } + + /// + /// Specialized class of for objects + /// + public class NavigatorWindowDocumentItem : NavigatorWindowItem + { + private string _infoTip; + + public string InfoTip + { + get + { + return _infoTip; + } + } + + private string _contentTypeDescription; + + public string ContentTypeDescription + { + get + { + return _contentTypeDescription; + } + } + + private DateTime _lastActivation; + + public DateTime LastActivation + { + get { return _lastActivation; } + } + + + internal NavigatorWindowDocumentItem(DocumentContent document) + : base(document) + { + _infoTip = document.InfoTip; + if (_infoTip == null && document.ToolTip != null && document.ToolTip is string) + _infoTip = document.ToolTip.ToString(); + + _contentTypeDescription = document.ContentTypeDescription; + _lastActivation = document.LastActivation; + } + + + } + + /// + /// Window that is automatically shown when user press Ctrl+Tab combination + /// + /// This window allow user to rapidly select a object or a object. + /// When selected a content is also activate with the function + public class NavigatorWindow : AvalonDockWindow + { + #region Constructors + static NavigatorWindow() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(NavigatorWindow), new FrameworkPropertyMetadata(typeof(NavigatorWindow))); + + AllowsTransparencyProperty.OverrideMetadata(typeof(NavigatorWindow), new FrameworkPropertyMetadata(true)); + WindowStyleProperty.OverrideMetadata(typeof(NavigatorWindow), new FrameworkPropertyMetadata(WindowStyle.None)); + ShowInTaskbarProperty.OverrideMetadata(typeof(NavigatorWindow), new FrameworkPropertyMetadata(false)); + BackgroundProperty.OverrideMetadata(typeof(NavigatorWindow), new FrameworkPropertyMetadata(Brushes.Transparent)); + } + + DockingManager _manager; + internal NavigatorWindow(DockingManager manager) + { + WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner; + + _manager = manager; + + List docs = new List(); + _manager.Documents.ForEach((DocumentContent doc) => + { + docs.Add(new NavigatorWindowDocumentItem(doc)); + }); + + docs.Sort((NavigatorWindowDocumentItem item1, NavigatorWindowDocumentItem item2) => + { + if (item1 == item2 || + item1.LastActivation == item2.LastActivation) + return 0; + return (item1.LastActivation < item2.LastActivation) ? 1 : -1; + }); + + SetDocuments(new CollectionView(docs)); + + List cnts = new List(); + _manager.DockableContents.Where(c => c.State != DockableContentState.Hidden).ForEach((DockableContent cnt) => + { + cnts.Add(new NavigatorWindowItem(cnt)); + }); + + SetDockableContents(new CollectionView(cnts)); + + Documents.MoveCurrentTo(Documents.OfType().FirstOrDefault(cntItem => + { + return cntItem.ItemContent == _manager.ActiveDocument; + })); + + DockableContents.MoveCurrentTo(null); + + Loaded += new RoutedEventHandler(NavigatorWindow_Loaded); + } + + #endregion + + #region Handlers for Tab+ctrl keys events + protected override void OnPreviewKeyDown(KeyEventArgs e) + { + if (e.Key != Key.Tab) + Hide(); + else + { + e.Handled = true; + MoveNextSelectedContent(); + } + + base.OnKeyDown(e); + } + + protected override void OnPreviewKeyUp(KeyEventArgs e) + { + if (e.Key != Key.Tab) + { + var docSelected = (Documents.CurrentItem as NavigatorWindowDocumentItem).ItemContent as DocumentContent; + docSelected.Activate(); + Hide(); + } + else + { + e.Handled = true; + } + + base.OnPreviewKeyUp(e); + } + + #endregion + + #region Current Document/Content changed + void NavigatorWindow_Loaded(object sender, RoutedEventArgs e) + { + Documents.CurrentChanged += new EventHandler(Documents_CurrentChanged); + DockableContents.CurrentChanged += new EventHandler(DockableContents_CurrentChanged); + } + + + void DockableContents_CurrentChanged(object sender, EventArgs e) + { + if (DockableContents.CurrentItem == null) + return; + + Debug.WriteLine(string.Format("DockContent current changed to {0}", (DockableContents.CurrentItem as NavigatorWindowItem).ItemContent.Title)); + var dockCntSelected = (DockableContents.CurrentItem as NavigatorWindowItem).ItemContent as DockableContent; + Hide(); + dockCntSelected.Activate(); + } + + void Documents_CurrentChanged(object sender, EventArgs e) + { + if (Documents.CurrentItem == null) + return; + if (_intMoveFlag) + return; + + Debug.WriteLine(string.Format("Document current changed to {0}", (Documents.CurrentItem as NavigatorWindowItem).ItemContent.Title)); + + var docSelected = (Documents.CurrentItem as NavigatorWindowDocumentItem).ItemContent as DocumentContent; + docSelected.Activate(); + Hide(); + } + #endregion + + #region Documents + + /// + /// Documents Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey DocumentsPropertyKey + = DependencyProperty.RegisterReadOnly("Documents", typeof(CollectionView), typeof(NavigatorWindow), + new FrameworkPropertyMetadata(null)); + + public static readonly DependencyProperty DocumentsProperty + = DocumentsPropertyKey.DependencyProperty; + + /// + /// Gets the Documents property. This dependency property + /// indicates documents currently hosted by parent . + /// + public CollectionView Documents + { + get { return (CollectionView)GetValue(DocumentsProperty); } + } + + /// + /// Provides a secure method for setting the Documents property. + /// This dependency property indicates documents currently hosted by parent . + /// + /// The new value for the property. + protected void SetDocuments(CollectionView value) + { + SetValue(DocumentsPropertyKey, value); + } + + #endregion + + #region DockableContents + + /// + /// DockableContents Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey DockableContentsPropertyKey + = DependencyProperty.RegisterReadOnly("DockableContents", typeof(CollectionView), typeof(NavigatorWindow), + new FrameworkPropertyMetadata((CollectionView)null)); + + public static readonly DependencyProperty DockableContentsProperty + = DockableContentsPropertyKey.DependencyProperty; + + /// + /// Gets the DockableContents property. This dependency property + /// indicates dockable contents hosted in parent object. + /// + public CollectionView DockableContents + { + get { return (CollectionView)GetValue(DockableContentsProperty); } + } + + /// + /// Provides a secure method for setting the DockableContents property. + /// This dependency property indicates dockable contents hosted in parent object. + /// + /// The new value for the property. + protected void SetDockableContents(CollectionView value) + { + SetValue(DockableContentsPropertyKey, value); + } + + #endregion + + #region Move to Next document + bool _intMoveFlag = false; + public void MoveNextSelectedContent() + { + _intMoveFlag = true; + if (!Documents.MoveCurrentToNext()) + Documents.MoveCurrentToFirst(); + if (Documents.IsCurrentAfterLast) + Documents.MoveCurrentToFirst(); + _intMoveFlag = false; + } + #endregion + } +} diff --git a/src/Libraries/AvalonDock/OverlayWindow.cs b/src/Libraries/AvalonDock/AvalonDock/OverlayWindow.cs similarity index 53% rename from src/Libraries/AvalonDock/OverlayWindow.cs rename to src/Libraries/AvalonDock/AvalonDock/OverlayWindow.cs index 00af4da30f..8f3b03e30a 100644 --- a/src/Libraries/AvalonDock/OverlayWindow.cs +++ b/src/Libraries/AvalonDock/AvalonDock/OverlayWindow.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -55,9 +55,13 @@ namespace AvalonDock DropBorderRight, DropBorderTop, DropBorderBottom, + DropMainPaneLeft, + DropMainPaneRight, + DropMainPaneTop, + DropMainPaneBottom, } - public class OverlayWindow : Window, INotifyPropertyChanged + public class OverlayWindow : AvalonDockWindow//, INotifyPropertyChanged { static OverlayWindow() { @@ -66,18 +70,41 @@ namespace AvalonDock Window.AllowsTransparencyProperty.OverrideMetadata(typeof(OverlayWindow), new FrameworkPropertyMetadata(true)); Window.WindowStyleProperty.OverrideMetadata(typeof(OverlayWindow), new FrameworkPropertyMetadata(WindowStyle.None)); Window.ShowInTaskbarProperty.OverrideMetadata(typeof(OverlayWindow), new FrameworkPropertyMetadata(false)); + Window.ShowActivatedProperty.OverrideMetadata(typeof(OverlayWindow), new FrameworkPropertyMetadata(false)); } - public OverlayWindow() - { } + public static object Theme; + + internal OverlayWindow() + { + + } DockingManager _manager = null; - public OverlayWindow(DockingManager manager) + internal OverlayWindow(DockingManager manager) { _manager = manager; } + FrameworkElement gridPaneRelativeDockingOptions; + FrameworkElement selectionBox; + + OverlayWindowDockingButton owdBottom; + OverlayWindowDockingButton owdTop; + OverlayWindowDockingButton owdLeft; + OverlayWindowDockingButton owdRight; + OverlayWindowDockingButton owdPaneBottom; + OverlayWindowDockingButton owdPaneTop; + OverlayWindowDockingButton owdPaneLeft; + OverlayWindowDockingButton owdPaneRight; + OverlayWindowDockingButton owdPaneInto; + + OverlayWindowDockingButton owdMainPaneBottom; + OverlayWindowDockingButton owdMainPaneTop; + OverlayWindowDockingButton owdMainPaneLeft; + OverlayWindowDockingButton owdMainPaneRight; + public override void OnApplyTemplate() { base.OnApplyTemplate(); @@ -96,122 +123,214 @@ namespace AvalonDock owdPaneRight = new OverlayWindowDockingButton(GetTemplateChild("PART_btnDockPaneRight") as FrameworkElement, this); owdPaneInto = new OverlayWindowDockingButton(GetTemplateChild("PART_btnDockPaneInto") as FrameworkElement, this); - _manager.DragPaneServices.Register(owdBottom); - _manager.DragPaneServices.Register(owdTop); - _manager.DragPaneServices.Register(owdLeft); - _manager.DragPaneServices.Register(owdRight); + var btn = GetTemplateChild("PART_btnDockMainPaneBottom") as FrameworkElement; + if (btn != null) owdMainPaneBottom = new OverlayWindowDockingButton(btn, this); + + btn = GetTemplateChild("PART_btnDockMainPaneTop") as FrameworkElement; + if (btn != null) owdMainPaneTop = new OverlayWindowDockingButton(btn, this); + + btn = GetTemplateChild("PART_btnDockMainPaneLeft") as FrameworkElement; + if (btn != null) owdMainPaneLeft = new OverlayWindowDockingButton(btn, this); + + btn = GetTemplateChild("PART_btnDockMainPaneRight") as FrameworkElement; + if (btn != null) owdMainPaneRight = new OverlayWindowDockingButton(btn, this); + + _manager.DragPaneServices.Register(owdPaneBottom); _manager.DragPaneServices.Register(owdPaneTop); _manager.DragPaneServices.Register(owdPaneLeft); _manager.DragPaneServices.Register(owdPaneRight); _manager.DragPaneServices.Register(owdPaneInto); + _manager.DragPaneServices.Register(owdBottom); + _manager.DragPaneServices.Register(owdTop); + _manager.DragPaneServices.Register(owdLeft); + _manager.DragPaneServices.Register(owdRight); + + if (owdMainPaneTop != null) _manager.DragPaneServices.Register(owdMainPaneTop); + if (owdMainPaneLeft != null) _manager.DragPaneServices.Register(owdMainPaneLeft); + if (owdMainPaneRight != null) _manager.DragPaneServices.Register(owdMainPaneRight); + if (owdMainPaneBottom != null) _manager.DragPaneServices.Register(owdMainPaneBottom); } - FrameworkElement gridPaneRelativeDockingOptions; - FrameworkElement selectionBox; + internal bool OnDrop(OverlayWindowDockingButton owdDock, Point point) + { + //calculate desidered size + Rect rectPane; - OverlayWindowDockingButton owdBottom; - OverlayWindowDockingButton owdTop; - OverlayWindowDockingButton owdLeft; - OverlayWindowDockingButton owdRight; - OverlayWindowDockingButton owdPaneBottom; - OverlayWindowDockingButton owdPaneTop; - OverlayWindowDockingButton owdPaneLeft; - OverlayWindowDockingButton owdPaneRight; - OverlayWindowDockingButton owdPaneInto; + switch (OverlayButtonHover) + { + case AvalonDock.OverlayButtonHover.DropBorderBottom: + case AvalonDock.OverlayButtonHover.DropBorderLeft: + case AvalonDock.OverlayButtonHover.DropBorderTop: + case AvalonDock.OverlayButtonHover.DropBorderRight: + rectPane = (_manager as IDropSurface).SurfaceRectangle; + break; + default: + rectPane = (CurrentDropPane as IDropSurface).SurfaceRectangle; + break; + } + + var desideredWidth = Math.Min( + rectPane.Width / 2.0, + ResizingPanel.GetEffectiveSize(_manager.DragPaneServices.FloatingWindow.HostedPane).Width); + var desideredHeight = Math.Min( + rectPane.Height / 2.0, + ResizingPanel.GetEffectiveSize(_manager.DragPaneServices.FloatingWindow.HostedPane).Height); + var desideredSize = new Size( + desideredWidth, + desideredHeight); - internal bool OnDrop(OverlayWindowDockingButton owdDock, Point point) - { //user has dropped the floating window over a anchor button //create a new dockable pane to insert in the main layout - Pane paneToAnchor = _manager.DragPaneServices.FloatingWindow.ClonePane(); - + //FIX: clone pane and return true only if overlayButtonOver is not set to None!! + + //floating window is going to be closed.. - - if (owdDock == owdBottom) - _manager.Anchor(paneToAnchor, AnchorStyle.Bottom); - else if (owdDock == owdLeft) - _manager.Anchor(paneToAnchor, AnchorStyle.Left); - else if (owdDock == owdRight) - _manager.Anchor(paneToAnchor, AnchorStyle.Right); - else if (owdDock == owdTop) - _manager.Anchor(paneToAnchor, AnchorStyle.Top); - else if (owdDock == owdPaneTop) - _manager.Anchor(paneToAnchor, CurrentDropPane, AnchorStyle.Top); - else if (owdDock == owdPaneBottom) - _manager.Anchor(paneToAnchor, CurrentDropPane, AnchorStyle.Bottom); - else if (owdDock == owdPaneLeft) - _manager.Anchor(paneToAnchor, CurrentDropPane, AnchorStyle.Left); - else if (owdDock == owdPaneRight) - _manager.Anchor(paneToAnchor, CurrentDropPane, AnchorStyle.Right); - else if (owdDock == owdPaneInto) - _manager.DropInto(paneToAnchor, CurrentDropPane); - selectionBox.Visibility = Visibility.Hidden; + //take the overlaybutton hover property to get the right button highlighted + switch (OverlayButtonHover) + { + case AvalonDock.OverlayButtonHover.DropBorderBottom: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane() as DockablePane, + AnchorStyle.Bottom); + break; + case AvalonDock.OverlayButtonHover.DropBorderTop: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane() as DockablePane, + AnchorStyle.Top); + break; + case AvalonDock.OverlayButtonHover.DropBorderLeft: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane() as DockablePane, + AnchorStyle.Left); + break; + case AvalonDock.OverlayButtonHover.DropBorderRight: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane() as DockablePane, + AnchorStyle.Right); + break; + case AvalonDock.OverlayButtonHover.DropPaneBottom: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane(), + CurrentDropPane, AnchorStyle.Bottom); + break; + case AvalonDock.OverlayButtonHover.DropPaneTop: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane(), + CurrentDropPane, AnchorStyle.Top); + break; + case AvalonDock.OverlayButtonHover.DropPaneLeft: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane(), + CurrentDropPane, AnchorStyle.Left); + break; + case AvalonDock.OverlayButtonHover.DropPaneRight: + _manager.Anchor( + _manager.DragPaneServices.FloatingWindow.ClonePane(), + CurrentDropPane, AnchorStyle.Right); + break; + case AvalonDock.OverlayButtonHover.DropPaneInto: + _manager.DropInto( + _manager.DragPaneServices.FloatingWindow.ClonePane(), + CurrentDropPane); + break; + default: + return false; + } + + return true; } Pane CurrentDropPane = null; - public void ShowOverlayPaneDockingOptions(Pane pane) + internal void ShowOverlayPaneDockingOptions(Pane paneOvering) { + var draggingPane = _manager.DragPaneServices.FloatingWindow.HostedPane; + var isDraggingADocumentPane = draggingPane is DocumentPane; + var isDraggingADockablePane = draggingPane is DockablePane; + + + HideOverlayPaneDockingOptions(paneOvering); + - HideOverlayPaneDockingOptions(pane); //check if dockable on a document pane - DockableStyle currentPaneDockableStyle = - _manager.DragPaneServices.FloatingWindow.HostedPane.GetCumulativeDockableStyle(); + DockableStyle currentPaneDockableStyle = + isDraggingADocumentPane ? + DockableStyle.Document : + (draggingPane as DockablePane).GetCumulativeDockableStyle(); //if current drop pane is a DocumentPane ... - if (pane is DocumentPane && + if (paneOvering is DocumentPane && (currentPaneDockableStyle & DockableStyle.Document) == 0) return; - if (pane is DockablePane && + if (paneOvering is DockablePane && (currentPaneDockableStyle & DockableStyle.Dockable) == 0) return; - Rect rectPane = pane.SurfaceRectangle; + Rect rectPane = (paneOvering as IDropSurface).SurfaceRectangle; Point myScreenTopLeft = this.PointToScreenDPI(new Point(0, 0)); rectPane.Offset(-myScreenTopLeft.X, -myScreenTopLeft.Y);//relative to me - gridPaneRelativeDockingOptions.SetValue(Canvas.LeftProperty, rectPane.Left + rectPane.Width / 2 - gridPaneRelativeDockingOptions.Width / 2); - gridPaneRelativeDockingOptions.SetValue(Canvas.TopProperty, rectPane.Top + rectPane.Height / 2 - gridPaneRelativeDockingOptions.Height / 2); - if (pane is DocumentPane) + gridPaneRelativeDockingOptions.SetValue(Canvas.LeftProperty, rectPane.Left); + gridPaneRelativeDockingOptions.SetValue(Canvas.TopProperty, rectPane.Top); + gridPaneRelativeDockingOptions.Width = rectPane.Width; + gridPaneRelativeDockingOptions.Height = rectPane.Height; + //gridPaneRelativeDockingOptions.SetValue(Canvas.LeftProperty, rectPane.Left + rectPane.Width / 2 - gridPaneRelativeDockingOptions.Width / 2); + //gridPaneRelativeDockingOptions.SetValue(Canvas.TopProperty, rectPane.Top + rectPane.Height / 2 - gridPaneRelativeDockingOptions.Height / 2); + + if (paneOvering is DocumentPane) gridPaneRelativeDockingOptions.Visibility = Visibility.Visible; else { - gridPaneRelativeDockingOptions.Visibility = !(_manager.DragPaneServices.FloatingWindow is DocumentFloatingWindow) ? Visibility.Visible : Visibility.Hidden; + gridPaneRelativeDockingOptions.Visibility = !isDraggingADocumentPane ? Visibility.Visible : Visibility.Hidden; } - owdBottom.Enabled = ((currentPaneDockableStyle & DockableStyle.BottomBorder) > 0); owdTop.Enabled = ((currentPaneDockableStyle & DockableStyle.TopBorder) > 0); owdLeft.Enabled = ((currentPaneDockableStyle & DockableStyle.LeftBorder) > 0); owdRight.Enabled = ((currentPaneDockableStyle & DockableStyle.RightBorder) > 0); - if (pane is DocumentPane) + if (paneOvering is DocumentPane) owdPaneInto.Enabled = true; else owdPaneInto.Enabled = !(_manager.DragPaneServices.FloatingWindow is DocumentFloatingWindow); - int destPaneChildCount = pane.Items.Count; + + if (paneOvering is DockablePane || isDraggingADocumentPane) + { + if (owdMainPaneBottom != null) owdMainPaneBottom.Enabled = false; + if (owdMainPaneTop != null) owdMainPaneTop.Enabled = false; + if (owdMainPaneLeft != null) owdMainPaneLeft.Enabled = false; + if (owdMainPaneRight != null) owdMainPaneRight.Enabled = false; + } + else if (isDraggingADockablePane) + { + if (owdMainPaneBottom != null) owdMainPaneBottom.Enabled = true; + if (owdMainPaneTop != null) owdMainPaneTop.Enabled = true; + if (owdMainPaneLeft != null) owdMainPaneLeft.Enabled = true; + if (owdMainPaneRight != null) owdMainPaneRight.Enabled = true; + } + + int destPaneChildCount = paneOvering.Items.Count; owdPaneBottom.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0; owdPaneTop.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0; owdPaneLeft.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0; owdPaneRight.Enabled = owdPaneInto.Enabled && destPaneChildCount > 0; - CurrentDropPane = pane; + CurrentDropPane = paneOvering; } - public void HideOverlayPaneDockingOptions(Pane surfaceElement) + internal void HideOverlayPaneDockingOptions(Pane surfaceElement) { - owdPaneBottom.Enabled = false; owdPaneTop.Enabled = false; owdPaneLeft.Enabled = false; @@ -220,7 +339,7 @@ namespace AvalonDock gridPaneRelativeDockingOptions.Visibility = Visibility.Collapsed; CurrentDropPane = null; - OverlayButtonHover = OverlayButtonHover.None; + SetOverlayButtonHover(OverlayButtonHover.None); } protected override void OnDeactivated(EventArgs e) @@ -232,11 +351,10 @@ namespace AvalonDock protected override void OnActivated(EventArgs e) { - base.OnActivated(e); - - DockableStyle currentPaneDockableStyle = - _manager.DragPaneServices.FloatingWindow.HostedPane.GetCumulativeDockableStyle(); + _manager.DragPaneServices.FloatingWindow.HostedPane is FloatingDocumentPane ? + DockableStyle.Document : + (_manager.DragPaneServices.FloatingWindow.HostedPane as DockablePane).GetCumulativeDockableStyle(); selectionBox.Visibility = Visibility.Hidden; @@ -244,6 +362,9 @@ namespace AvalonDock owdTop.Enabled = (currentPaneDockableStyle & DockableStyle.TopBorder) > 0; owdLeft.Enabled = (currentPaneDockableStyle & DockableStyle.LeftBorder) > 0; owdRight.Enabled = (currentPaneDockableStyle & DockableStyle.RightBorder) > 0; + + + base.OnActivated(e); } /// @@ -267,7 +388,7 @@ namespace AvalonDock { selectionBox.Visibility = Visibility.Hidden; _manager.DragPaneServices.FloatingWindow.OnHideSelectionBox(); - OverlayButtonHover = OverlayButtonHover.None; + SetOverlayButtonHover(OverlayButtonHover.None); } internal void OnDragOver(OverlayWindowDockingButton owdDock, Point point) @@ -281,9 +402,9 @@ namespace AvalonDock owdDock == owdLeft || owdDock == owdTop || owdDock == owdRight) - rectPane = _manager.SurfaceRectangle; + rectPane = (_manager as IDropSurface).SurfaceRectangle; else - rectPane = CurrentDropPane.SurfaceRectangle; + rectPane = (CurrentDropPane as IDropSurface).SurfaceRectangle; double selectionBoxWidth = Math.Min( rectPane.Width / 2.0, @@ -333,25 +454,25 @@ namespace AvalonDock } if (owdDock == owdLeft) - OverlayButtonHover = OverlayButtonHover.DropBorderLeft; + SetOverlayButtonHover(OverlayButtonHover.DropBorderLeft);//OverlayButtonHover = OverlayButtonHover.DropBorderLeft; else if (owdDock == owdRight) - OverlayButtonHover = OverlayButtonHover.DropBorderRight; + SetOverlayButtonHover(OverlayButtonHover.DropBorderRight);//OverlayButtonHover = OverlayButtonHover.DropBorderRight; else if (owdDock == owdTop) - OverlayButtonHover = OverlayButtonHover.DropBorderTop; + SetOverlayButtonHover(OverlayButtonHover.DropBorderTop);//OverlayButtonHover = OverlayButtonHover.DropBorderTop; else if (owdDock == owdBottom) - OverlayButtonHover = OverlayButtonHover.DropBorderBottom; + SetOverlayButtonHover(OverlayButtonHover.DropBorderBottom);//OverlayButtonHover = OverlayButtonHover.DropBorderBottom; else if (owdDock == owdPaneInto) - OverlayButtonHover = OverlayButtonHover.DropPaneInto; + SetOverlayButtonHover(OverlayButtonHover.DropPaneInto);//OverlayButtonHover = OverlayButtonHover.DropPaneInto; else if (owdDock == owdPaneRight) - OverlayButtonHover = OverlayButtonHover.DropPaneRight; + SetOverlayButtonHover(OverlayButtonHover.DropPaneRight);//OverlayButtonHover = OverlayButtonHover.DropPaneRight; else if (owdDock == owdPaneTop) - OverlayButtonHover = OverlayButtonHover.DropPaneTop; + SetOverlayButtonHover(OverlayButtonHover.DropPaneTop);//OverlayButtonHover = OverlayButtonHover.DropPaneTop; else if (owdDock == owdPaneLeft) - OverlayButtonHover = OverlayButtonHover.DropPaneLeft; + SetOverlayButtonHover(OverlayButtonHover.DropPaneLeft);//OverlayButtonHover = OverlayButtonHover.DropPaneLeft; else if (owdDock == owdPaneBottom) - OverlayButtonHover = OverlayButtonHover.DropPaneBottom; + SetOverlayButtonHover(OverlayButtonHover.DropPaneBottom);//OverlayButtonHover = OverlayButtonHover.DropPaneBottom; else - OverlayButtonHover = OverlayButtonHover.None; + SetOverlayButtonHover(OverlayButtonHover.None);//OverlayButtonHover = OverlayButtonHover.None; selectionBox.Visibility = Visibility.Visible; @@ -360,23 +481,37 @@ namespace AvalonDock } - OverlayButtonHover _overlayButtonHover = OverlayButtonHover.None; + #region OverlayButtonHover + /// + /// OverlayButtonHover Read-Only Dependency Property + /// + private static readonly DependencyPropertyKey OverlayButtonHoverPropertyKey + = DependencyProperty.RegisterReadOnly("OverlayButtonHover", typeof(OverlayButtonHover), typeof(OverlayWindow), + new FrameworkPropertyMetadata(OverlayButtonHover.None)); + + public static readonly DependencyProperty OverlayButtonHoverProperty + = OverlayButtonHoverPropertyKey.DependencyProperty; + + /// + /// Gets the OverlayButtonHover property. This dependency property + /// indicates .... + /// public OverlayButtonHover OverlayButtonHover { - get - { return _overlayButtonHover; } - set - { - _overlayButtonHover = value; - if (PropertyChanged != null) - PropertyChanged(this, new PropertyChangedEventArgs("OverlayButtonHover")); - } + get { return (OverlayButtonHover)GetValue(OverlayButtonHoverProperty); } } - #region INotifyPropertyChanged Members + /// + /// Provides a secure method for setting the OverlayButtonHover property. + /// This dependency property indicates indicates which anchor button is currently highlighted by user. + /// + /// The new value for the property. + protected void SetOverlayButtonHover(OverlayButtonHover value) + { + SetValue(OverlayButtonHoverPropertyKey, value); + } - public event PropertyChangedEventHandler PropertyChanged; #endregion } diff --git a/src/Libraries/AvalonDock/OverlayWindowAnchorButton.cs b/src/Libraries/AvalonDock/AvalonDock/OverlayWindowAnchorButton.cs similarity index 85% rename from src/Libraries/AvalonDock/OverlayWindowAnchorButton.cs rename to src/Libraries/AvalonDock/AvalonDock/OverlayWindowAnchorButton.cs index ee07a4aa09..f7395a7b62 100644 --- a/src/Libraries/AvalonDock/OverlayWindowAnchorButton.cs +++ b/src/Libraries/AvalonDock/AvalonDock/OverlayWindowAnchorButton.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -42,6 +42,11 @@ namespace AvalonDock } public OverlayWindowDockingButton(FrameworkElement btnDock, OverlayWindow owner, bool enabled) { + if (btnDock == null) + throw new ArgumentNullException("btnDock"); + if (owner == null) + throw new ArgumentNullException("owner"); + _btnDock = btnDock; _owner = owner; Enabled = enabled; @@ -69,11 +74,11 @@ namespace AvalonDock - public Rect SurfaceRectangle + Rect IDropSurface.SurfaceRectangle { get { - if (!IsSurfaceVisible) + if (!(this as IDropSurface).IsSurfaceVisible) return Rect.Empty; if (PresentationSource.FromVisual(_btnDock) == null) @@ -83,7 +88,7 @@ namespace AvalonDock } } - public void OnDragEnter(Point point) + void IDropSurface.OnDragEnter(Point point) { if (!Enabled) return; @@ -91,7 +96,7 @@ namespace AvalonDock _owner.OnDragEnter(this, point); } - public void OnDragOver(Point point) + void IDropSurface.OnDragOver(Point point) { if (!Enabled) return; @@ -99,7 +104,7 @@ namespace AvalonDock _owner.OnDragOver(this, point); } - public void OnDragLeave(Point point) + void IDropSurface.OnDragLeave(Point point) { if (!Enabled) return; @@ -107,7 +112,7 @@ namespace AvalonDock _owner.OnDragLeave(this, point); } - public bool OnDrop(Point point) + bool IDropSurface.OnDrop(Point point) { if (!Enabled) return false; @@ -115,7 +120,7 @@ namespace AvalonDock return _owner.OnDrop(this, point); } - public bool IsSurfaceVisible + bool IDropSurface.IsSurfaceVisible { get { return (_owner.IsLoaded && _btnDock != null); } } diff --git a/src/Libraries/AvalonDock/AvalonDock/Pane.cs b/src/Libraries/AvalonDock/AvalonDock/Pane.cs new file mode 100644 index 0000000000..3171e884ee --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Pane.cs @@ -0,0 +1,472 @@ +//Copyright (c) 2007-2010, Adolfo Marinucci +//All rights reserved. + +//Redistribution and use in source and binary forms, with or without modification, +//are permitted provided that the following conditions are met: +// +//* Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +//* Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +//* Neither the name of Adolfo Marinucci nor the names of its contributors may +// be used to endorse or promote products derived from this software without +// specific prior written permission. +// +//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Diagnostics; +using System.ComponentModel; +using System.Collections; +using System.Linq; + +namespace AvalonDock +{ + public abstract class Pane : + System.Windows.Controls.Primitives.Selector, + IDropSurface, + IDockableControl, + INotifyPropertyChanged + { + static Pane() + { + //FocusableProperty.OverrideMetadata(typeof(Pane), new FrameworkPropertyMetadata(false)); + } + + internal Pane() + { + this.Loaded += new RoutedEventHandler(OnLoaded); + this.Unloaded += new RoutedEventHandler(OnUnloaded); + } + + protected virtual void OnLoaded(object sender, RoutedEventArgs e) + { + //if (GetManager() == null && Parent != null) + // throw new InvalidOperationException("Pane must be put under a DockingManager!"); + + AddDragPaneReferences(); + } + + protected virtual void OnUnloaded(object sender, RoutedEventArgs e) + { + RemoveDragPaneReferences(); + } + + #region Contents management + public bool HasSingleItem + { + get + { + return (bool)GetValue(HasSingleItemProperty); + } + protected set { SetValue(HasSingleItemPropertyKey, value); } + } + + // Using a DependencyProperty as the backing store for HasSingleItem. This enables animation, styling, binding, etc... + private static readonly DependencyPropertyKey HasSingleItemPropertyKey = + DependencyProperty.RegisterReadOnly("HasSingleItem", typeof(bool), typeof(Pane), new PropertyMetadata(false)); + + public static readonly DependencyProperty HasSingleItemProperty = HasSingleItemPropertyKey.DependencyProperty; + + + ManagedContent _lastSelectedContent = null; + protected override void OnSelectionChanged(SelectionChangedEventArgs e) + { + if (e.RemovedItems != null && + e.RemovedItems.Count > 0 && + e.AddedItems != null && + e.AddedItems.Count > 0) + _lastSelectedContent = e.RemovedItems[0] as ManagedContent; + + base.OnSelectionChanged(e); + } + + protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { + DockingManager dockManager = GetManager(); + if (dockManager != null) + dockManager.RefreshContents(); + + if (e.NewItems != null) + CheckItems(e.NewItems); + + HasSingleItem = (Items.Count == 1); + + if (_lastSelectedContent != null && + !Items.Contains(_lastSelectedContent)) + _lastSelectedContent = null; + + if ((e.NewItems == null || e.NewItems.Count == 0) && + (e.OldItems != null && e.OldItems.Count > 0)) + { + if (_lastSelectedContent != null && + Items.Contains(_lastSelectedContent)) + SelectedItem = _lastSelectedContent; + } + + if (Items.Count > 0) + { + int currentIndex = SelectedIndex; + + if (currentIndex < 0 || + currentIndex >= Items.Count) + currentIndex = Items.Count - 1; + + SelectedItem = Items.GetItemAt(currentIndex); + } + + RefreshContainsActiveContentProperty(); + + if (Items.Count > 0) + { + var parentPanel = Parent as ResizingPanel; + while (parentPanel != null && parentPanel.IsLoaded) + { + parentPanel.UpdateLayout(); + parentPanel.InvalidateMeasure(); + parentPanel = parentPanel.Parent as ResizingPanel; + } + } + + base.OnItemsChanged(e); + } + + protected override void OnVisualParentChanged(DependencyObject oldParent) + { + DockingManager dockManager = GetManager(); + if (dockManager != null) + dockManager.RefreshContents(); + + base.OnVisualParentChanged(oldParent); + } + + protected virtual void CheckItems(IList newItems) + { + foreach (object newItem in newItems) + { + if (!(newItem is ManagedContent)) + throw new InvalidOperationException("Pane can contain only ManagedContents!"); + } + } + + //void RefreshContentsSelectedProperty() + //{ + // //foreach (ManagedContent mc in Items) + // //{ + // // //mc.IsSelected = (mc == SelectedItem); + // // //Selector.SetIsSelected(mc + + // // if (Selector.GetIsSelected(mc)) + // // mc.FocusContent(); + // //} + //} + + //protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) + //{ + // if (e.Property == SelectedItemProperty) + // RefreshContentsSelectedProperty(); + // // SetValue(ActiveContentProperty, SelectedItem); + + // //if (e.Property == ActiveContentProperty) + // //{ + // // //SetValue(SelectedItemProperty, ActiveContent); + + // //} + + // base.OnPropertyChanged(e); + //} + #endregion + + #region IDockableControl Members + + public virtual bool IsDocked + { + get { return true; } + } + + #endregion + + public virtual DockingManager GetManager() + { + DependencyObject parent = LogicalTreeHelper.GetParent(this); + + while (parent != null && + (!(parent is DockingManager))) + parent = LogicalTreeHelper.GetParent(parent); + + return parent as DockingManager; + } + + #region ContainsActiveContent + + /// + /// ContainsActiveContent Read-Only Dependency Property + /// + /// This property is specially intended for use in restyling. + private static readonly DependencyPropertyKey ContainsActiveContentPropertyKey + = DependencyProperty.RegisterReadOnly("ContainsActiveContent", typeof(bool), typeof(Pane), + new FrameworkPropertyMetadata(false, + new PropertyChangedCallback(OnContainsActiveContentChanged))); + + public static readonly DependencyProperty ContainsActiveContentProperty + = ContainsActiveContentPropertyKey.DependencyProperty; + + /// + /// Gets the ContainsActiveContent property. This dependency property + /// indicates if this contains a set as active content into the parent object. + /// + public bool ContainsActiveContent + { + get { return (bool)GetValue(ContainsActiveContentProperty); } + } + + /// + /// Provides a secure method for setting the ContainsActiveContent property. + /// This dependency property indicates if this contains a set as active content into the parent object. + /// + /// The new value for the property. + protected void SetContainsActiveContent(bool value) + { + SetValue(ContainsActiveContentPropertyKey, value); + } + + /// + /// Handles changes to the ContainsActiveContent property. + /// + private static void OnContainsActiveContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((Pane)d).OnContainsActiveContentChanged(e); + } + + /// + /// Provides derived classes an opportunity to handle changes to the ContainsActiveContent property. + /// + protected virtual void OnContainsActiveContentChanged(DependencyPropertyChangedEventArgs e) + { + } + + + internal void RefreshContainsActiveContentProperty() + { + SetContainsActiveContent( + Items.Cast().FirstOrDefault(d => d.IsActiveContent) != null); + + if (Items.Count> 0) + Debug.WriteLine("{0} ContainsActiveContent ={1}", (Items[0] as ManagedContent).Title, ContainsActiveContent); + } + #endregion + + #region IDockableControl Members + + #endregion + + #region Membri di IDropSurface + #region Drag pane services + + DockingManager _oldManager = null; + + protected void RemoveDragPaneReferences() + { + if (!DesignerProperties.GetIsInDesignMode(this)) + { + if (_oldManager != null) + { + _oldManager.DragPaneServices.Unregister(this); + _oldManager = null; + } + } + } + + protected void AddDragPaneReferences() + { + if (!DesignerProperties.GetIsInDesignMode(this)) + { + _oldManager = GetManager(); + if (_oldManager != null) + _oldManager.DragPaneServices.Register(this); + } + } + #endregion + + protected abstract bool IsSurfaceVisible + { + get; + } + + bool IDropSurface.IsSurfaceVisible { get { return IsSurfaceVisible; } } + + + protected virtual Rect SurfaceRectangle + { + get + { + if (!IsSurfaceVisible) + return new Rect(); + + if (PresentationSource.FromVisual(this) == null) + return new Rect(); + + return new Rect(HelperFunc.PointToScreenWithoutFlowDirection(this, new Point()), new Size(ActualWidth, ActualHeight)); + } + } + Rect IDropSurface.SurfaceRectangle + { + get { return SurfaceRectangle; } + } + + protected virtual void OnDragEnter(Point point) + { + GetManager().OverlayWindow.ShowOverlayPaneDockingOptions(this); + } + void IDropSurface.OnDragEnter(Point point) + { + OnDragEnter(point); + } + + protected virtual void OnDragOver(Point point) + { + + } + + void IDropSurface.OnDragOver(Point point) + { + OnDragOver(point); + } + + protected virtual void OnDragLeave(Point point) + { + GetManager().OverlayWindow.HideOverlayPaneDockingOptions(this); + } + + + void IDropSurface.OnDragLeave(Point point) + { + OnDragLeave(point); + } + + + protected virtual bool OnDrop(Point point) + { + return false; + } + + bool IDropSurface.OnDrop(Point point) + { + return OnDrop(point); + } + + #endregion + + #region Commands + protected override void OnInitialized(EventArgs e) + { + this.CommandBindings.Add( + new CommandBinding(PaneCommands.Dock, this.OnExecuteCommand, this.OnCanExecuteCommand)); + + base.OnInitialized(e); + } + + protected virtual void OnExecuteCommand(object sender, ExecutedRoutedEventArgs e) + { + if (e.Command == PaneCommands.Dock) + { + Dock(); + e.Handled = true; + } + } + + protected virtual void OnCanExecuteCommand(object sender, CanExecuteRoutedEventArgs e) + { + e.CanExecute = this.GetManager() != null; + + if (e.CanExecute) + { + if (e.Command == PaneCommands.Dock) + { + e.CanExecute = true; + } + } + + Debug.WriteLine("Pane.OnCanExecuteCommand({0}) = {1} (ContinueRouting={2})", e.Command, e.CanExecute, e.ContinueRouting); + } + + /// + /// Dock contained contents to the container + /// + public virtual void Dock() + { + + } + #endregion + + internal virtual ManagedContent RemoveContent(ManagedContent contentToRemove) + { + Items.Remove(contentToRemove); + + return contentToRemove; + } + + + internal virtual ManagedContent RemoveContent(int index) + { + ManagedContent contentToRemove = Items[index] as ManagedContent; + + return RemoveContent(contentToRemove); + } + + protected FrameworkElement _partHeader = null; + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + //gets a reference to the header for the pane + _partHeader = GetTemplateChild("PART_Header") as FrameworkElement; + } + + internal virtual ResizingPanel GetContainerPanel() + { + return LogicalTreeHelper.GetParent(this) as ResizingPanel; + } + + + /// + /// Gest or set a value indicating if pane should show the tab header + /// + public bool ShowHeader + { + get { return (bool)GetValue(ShowHeaderProperty); } + set { SetValue(ShowHeaderProperty, value); } + } + + // Using a DependencyProperty as the backing store for ActiveContent. This enables animation, styling, binding, etc... + public static readonly DependencyProperty ShowHeaderProperty = + DependencyProperty.Register("ShowHeader", typeof(bool), typeof(Pane), new UIPropertyMetadata(true)); + + + + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + internal void NotifyPropertyChanged(string propertyName) + { + if (PropertyChanged != null) + PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + #endregion + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/PaneCommands.cs b/src/Libraries/AvalonDock/AvalonDock/PaneCommands.cs new file mode 100644 index 0000000000..93d7cdfbaf --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/PaneCommands.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace AvalonDock +{ + public sealed class PaneCommands + { + static object syncRoot = new object(); + + + + + private static RoutedUICommand dockCommand = null; + + /// + /// Dock to container + /// + public static RoutedUICommand Dock + { + get + { + lock (syncRoot) + { + if (null == dockCommand) + { + dockCommand = new RoutedUICommand("Dock", "Dock", typeof(PaneCommands)); + } + } + return dockCommand; + } + } + + } +} diff --git a/src/Libraries/AvalonDock/PaneTabPanel.cs b/src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs similarity index 64% rename from src/Libraries/AvalonDock/PaneTabPanel.cs rename to src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs index 75c10b190a..24857f6bc8 100644 --- a/src/Libraries/AvalonDock/PaneTabPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/PaneTabPanel.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -35,11 +35,12 @@ using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; - +using System.Linq; +using System.Windows.Markup; namespace AvalonDock { - public abstract class PaneTabPanel : System.Windows.Controls.Panel + public abstract class PaneTabPanel : Panel { //static PaneTabPanel() //{ @@ -47,31 +48,73 @@ namespace AvalonDock // //This style is defined in themes\generic.xaml // DefaultStyleKeyProperty.OverrideMetadata(typeof(PaneTabPanel), new FrameworkPropertyMetadata(typeof(PaneTabPanel))); //} - + protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) { base.OnVisualChildrenChanged(visualAdded, visualRemoved); - + ManagedContent mc = visualAdded as ManagedContent; if (mc != null) { - mc.Style = null; mc.Style = TabItemStyle; + mc.ApplyTemplate(); } } + internal PaneTabPanel() + { + + } + + #region TabItemStyle + + /// + /// TabItemStyle Dependency Property + /// + public static readonly DependencyProperty TabItemStyleProperty = + DependencyProperty.Register("TabItemStyle", typeof(Style), typeof(PaneTabPanel), + new FrameworkPropertyMetadata((Style)null, + new PropertyChangedCallback(OnTabItemStyleChanged))); + /// + /// Gets or sets the TabItemStyle property. This dependency property + /// indicates style to use for tabs. + /// public Style TabItemStyle { get { return (Style)GetValue(TabItemStyleProperty); } set { SetValue(TabItemStyleProperty, value); } } - // Using a DependencyProperty as the backing store for TabStyle. This enables animation, styling, binding, etc... - public static readonly DependencyProperty TabItemStyleProperty = - DependencyProperty.Register("TabItemStyle", typeof(Style), typeof(PaneTabPanel)); + /// + /// Handles changes to the TabItemStyle property. + /// + private static void OnTabItemStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + ((PaneTabPanel)d).OnTabItemStyleChanged(e); + } + + /// + /// Provides derived classes an opportunity to handle changes to the TabItemStyle property. + /// + protected virtual void OnTabItemStyleChanged(DependencyPropertyChangedEventArgs e) + { + //Children.Cast().ForEach(c => + // { + // Binding bnd = new Binding("TabItemStyle"); + // bnd.Source = this; + // bnd.Mode = BindingMode.OneWay; + + // c.SetBinding(StyleProperty, bnd); + + // //c.Style = TabItemStyle; + // }); + } + + + #endregion } } diff --git a/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs b/src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs similarity index 52% rename from src/Libraries/AvalonDock/Properties/AssemblyInfo.cs rename to src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs index 6b9b29848c..8db8b6927e 100644 --- a/src/Libraries/AvalonDock/Properties/AssemblyInfo.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/AssemblyInfo.cs @@ -1,25 +1,24 @@ -#region Using directives - -using System.Reflection; -using System.Runtime.CompilerServices; +using System.Reflection; using System.Resources; -using System.Globalization; -using System.Windows; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; - -#endregion +using System.Windows; // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("AvalonDock")] -[assembly: AssemblyDescription("WPF docking library")] +[assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] +[assembly: AssemblyCompany("Adolfo Marinucci")] [assembly: AssemblyProduct("AvalonDock")] -[assembly: AssemblyCopyright("Copyright @ Adolfo Marinucci 2007-2009")] +[assembly: AssemblyCopyright("Copyright © Adolfo Marinucci 2010")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. [assembly: ComVisible(false)] //In order to begin building localizable applications, set @@ -32,22 +31,14 @@ using System.Runtime.InteropServices; //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] -// Specifies the location in which theme dictionaries are stored for types in an assembly. [assembly: ThemeInfo( - // Specifies the location of system theme-specific resource dictionaries for this project. - // The default setting in this project is "None" since this default project does not - // include these user-defined theme files: - // Themes\Aero.NormalColor.xaml - // Themes\Classic.xaml - // Themes\Luna.Homestead.xaml - // Themes\Luna.Metallic.xaml - // Themes\Luna.NormalColor.xaml - // Themes\Royale.NormalColor.xaml - ResourceDictionaryLocation.SourceAssembly, - - // Specifies the location of the system non-theme specific resource dictionary: - // Themes\generic.xaml - ResourceDictionaryLocation.SourceAssembly)] + ResourceDictionaryLocation.SourceAssembly, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] // Version information for an assembly consists of the following four values: @@ -57,6 +48,8 @@ using System.Runtime.InteropServices; // Build Number // Revision // -// You can specify all the values or you can default the Revision and Build Numbers +// You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.2.2702")] +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.3.3391")] +[assembly: AssemblyFileVersion("1.3.3391")] diff --git a/src/Libraries/AvalonDock/AvalonDock/Properties/Resources.Designer.cs b/src/Libraries/AvalonDock/AvalonDock/Properties/Resources.Designer.cs new file mode 100644 index 0000000000..474b94b1bf --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/Resources.Designer.cs @@ -0,0 +1,252 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AvalonDock.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AvalonDock.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Float. + /// + public static string DockableContentCommands_DockableFloatingWindow { + get { + return ResourceManager.GetString("DockableContentCommands_DockableFloatingWindow", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Float. + /// + public static string DockableContentCommands_FloatingWindow { + get { + return ResourceManager.GetString("DockableContentCommands_FloatingWindow", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Dock as Tabbed Document. + /// + public static string DockableContentCommands_ShowAsDocument { + get { + return ResourceManager.GetString("DockableContentCommands_ShowAsDocument", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Auto Hide. + /// + public static string DockableContentCommands_ToggleAutoHide { + get { + return ResourceManager.GetString("DockableContentCommands_ToggleAutoHide", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Window Position. + /// + public static string DockablePane_ShowOptionsMenu { + get { + return ResourceManager.GetString("DockablePane_ShowOptionsMenu", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close. + /// + public static string DockablePaneCommands_Close { + get { + return ResourceManager.GetString("DockablePaneCommands_Close", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide. + /// + public static string DockablePaneCommands_Hide { + get { + return ResourceManager.GetString("DockablePaneCommands_Hide", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Auto Hide. + /// + public static string DockablePaneCommands_ToggleAutoHide { + get { + return ResourceManager.GetString("DockablePaneCommands_ToggleAutoHide", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Float. + /// + public static string DocumentContentCommands_FloatingDocument { + get { + return ResourceManager.GetString("DocumentContentCommands_FloatingDocument", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Dock as Tabbed Document. + /// + public static string DocumentContentCommands_TabbedDocument { + get { + return ResourceManager.GetString("DocumentContentCommands_TabbedDocument", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close All But This. + /// + public static string DocumentPaneCommands_CloseAllButThis { + get { + return ResourceManager.GetString("DocumentPaneCommands_CloseAllButThis", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close. + /// + public static string DocumentPaneCommands_CloseThis { + get { + return ResourceManager.GetString("DocumentPaneCommands_CloseThis", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New Horizontal Tab Group. + /// + public static string DocumentPaneCommands_NewHorizontalTabGroup { + get { + return ResourceManager.GetString("DocumentPaneCommands_NewHorizontalTabGroup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to New VerticalTab Group. + /// + public static string DocumentPaneCommands_NewVerticalTabGroup { + get { + return ResourceManager.GetString("DocumentPaneCommands_NewVerticalTabGroup", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Activate. + /// + public static string ManagedContentCommands_Activate { + get { + return ResourceManager.GetString("ManagedContentCommands_Activate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Close. + /// + public static string ManagedContentCommands_Close { + get { + return ResourceManager.GetString("ManagedContentCommands_Close", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Hide. + /// + public static string ManagedContentCommands_Hide { + get { + return ResourceManager.GetString("ManagedContentCommands_Hide", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Show. + /// + public static string ManagedContentCommands_Show { + get { + return ResourceManager.GetString("ManagedContentCommands_Show", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Active Files. + /// + public static string NavigatorWindow_ActiveFiles { + get { + return ResourceManager.GetString("NavigatorWindow_ActiveFiles", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Active Tool Windows. + /// + public static string NavigatorWindow_ActiveToolWindows { + get { + return ResourceManager.GetString("NavigatorWindow_ActiveToolWindows", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Dock. + /// + public static string PaneCommands_Dock { + get { + return ResourceManager.GetString("PaneCommands_Dock", resourceCulture); + } + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/Properties/Resources.resx b/src/Libraries/AvalonDock/AvalonDock/Properties/Resources.resx new file mode 100644 index 0000000000..b83816f7c1 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/Resources.resx @@ -0,0 +1,183 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Float + + + Float + + + Dock as Tabbed Document + + + Auto Hide + + + Close + + + Hide + + + Auto Hide + + + Window Position + + + Float + + + Dock as Tabbed Document + + + Close All But This + + + Close + + + New Horizontal Tab Group + + + New VerticalTab Group + + + Activate + + + Close + + + Hide + + + Show + + + Active Files + + + Active Tool Windows + + + Dock + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs b/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs new file mode 100644 index 0000000000..6ae5f90b65 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AvalonDock.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.settings b/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.settings new file mode 100644 index 0000000000..033d7a5e9e --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/RequestDocumentCloseEventArgs.cs b/src/Libraries/AvalonDock/AvalonDock/RequestDocumentCloseEventArgs.cs similarity index 100% rename from src/Libraries/AvalonDock/RequestDocumentCloseEventArgs.cs rename to src/Libraries/AvalonDock/AvalonDock/RequestDocumentCloseEventArgs.cs diff --git a/src/Libraries/AvalonDock/ResizingPanelSplitter.cs b/src/Libraries/AvalonDock/AvalonDock/Resizer.cs similarity index 55% rename from src/Libraries/AvalonDock/ResizingPanelSplitter.cs rename to src/Libraries/AvalonDock/AvalonDock/Resizer.cs index e13684f1bd..1125a53a7d 100644 --- a/src/Libraries/AvalonDock/ResizingPanelSplitter.cs +++ b/src/Libraries/AvalonDock/AvalonDock/Resizer.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -38,38 +38,18 @@ using System.Windows.Shapes; namespace AvalonDock { - public class ResizingPanelSplitter : System.Windows.Controls.Primitives.Thumb + public class Resizer : Thumb { - static ResizingPanelSplitter() + static Resizer() { //This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class. //This style is defined in themes\generic.xaml - DefaultStyleKeyProperty.OverrideMetadata(typeof(ResizingPanelSplitter), new FrameworkPropertyMetadata(typeof(ResizingPanelSplitter))); - MinWidthProperty.OverrideMetadata(typeof(ResizingPanelSplitter), new FrameworkPropertyMetadata(4.0, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); - MinHeightProperty.OverrideMetadata(typeof(ResizingPanelSplitter), new FrameworkPropertyMetadata(4.0, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); - HorizontalAlignmentProperty.OverrideMetadata(typeof(ResizingPanelSplitter), new FrameworkPropertyMetadata(HorizontalAlignment.Stretch, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); - VerticalAlignmentProperty.OverrideMetadata(typeof(ResizingPanelSplitter), new FrameworkPropertyMetadata(VerticalAlignment.Stretch, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); + DefaultStyleKeyProperty.OverrideMetadata(typeof(Resizer), new FrameworkPropertyMetadata(typeof(Resizer))); + MinWidthProperty.OverrideMetadata(typeof(Resizer), new FrameworkPropertyMetadata(6.0, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); + MinHeightProperty.OverrideMetadata(typeof(Resizer), new FrameworkPropertyMetadata(6.0, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); + HorizontalAlignmentProperty.OverrideMetadata(typeof(Resizer), new FrameworkPropertyMetadata(HorizontalAlignment.Stretch, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); + VerticalAlignmentProperty.OverrideMetadata(typeof(Resizer), new FrameworkPropertyMetadata(VerticalAlignment.Stretch, FrameworkPropertyMetadataOptions.AffectsParentMeasure)); } - public Orientation Orientation - { - get { return (Orientation)GetValue(OrientationProperty); } - protected set { SetValue(OrientationPropertyKey, value); } - } - - // Using a DependencyProperty as the backing store for Orientation. This enables animation, styling, binding, etc... - private static readonly DependencyPropertyKey OrientationPropertyKey = - DependencyProperty.RegisterReadOnly("Orientation", typeof(Orientation), typeof(ResizingPanelSplitter), new UIPropertyMetadata(Orientation.Horizontal)); - - public static readonly DependencyProperty OrientationProperty = OrientationPropertyKey.DependencyProperty; - - protected override void OnVisualParentChanged(DependencyObject oldParent) - { - ResizingPanel panel = Parent as ResizingPanel; - if (panel != null) - Orientation = panel.Orientation; - - base.OnVisualParentChanged(oldParent); - } } } diff --git a/src/Libraries/AvalonDock/ResizingPanel.cs b/src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs similarity index 75% rename from src/Libraries/AvalonDock/ResizingPanel.cs rename to src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs index 06c8e9caa6..48108b286e 100644 --- a/src/Libraries/AvalonDock/ResizingPanel.cs +++ b/src/Libraries/AvalonDock/AvalonDock/ResizingPanel.cs @@ -1,4 +1,4 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -145,14 +145,14 @@ namespace AvalonDock DependencyProperty.RegisterAttached("EffectiveSize", typeof(Size), typeof(ResizingPanel), new FrameworkPropertyMetadata(new Size())); - List _splitterList = new List(); + List _splitterList = new List(); /// /// Correct sizes of children if all of them are set to absolutes /// void CorrectSizes() { - IEnumerable children = Children.OfType().Where(c => !(c is ResizingPanelSplitter)); + IEnumerable children = Children.OfType().Where(c => !(c is Resizer)); if (children.All(c => c.IsAbsolute())) { @@ -172,7 +172,7 @@ namespace AvalonDock /// internal void AdjustPanelSizes() { - IEnumerable children = Children.OfType().Where(c => !(c is ResizingPanelSplitter)); + IEnumerable children = Children.OfType().Where(c => !(c is Resizer)); if (!this.IsLogicalChildContained()) { @@ -202,6 +202,8 @@ namespace AvalonDock /// protected override Size MeasureOverride(Size availableSize) { + //Debug.WriteLine("ResizingPanel.MeasureOverride()"); + SetupSplitters(); CorrectSizes(); @@ -222,13 +224,13 @@ namespace AvalonDock i > 0) { child = GetVisualChild(i - 1) as FrameworkElement; - Debug.Assert(child is ResizingPanelSplitter); + Debug.Assert(child is Resizer); child.Measure(Size.Empty); if (visibleChildren.Count > 0) { - Debug.Assert(visibleChildren[visibleChildren.Count - 1] is ResizingPanelSplitter); + Debug.Assert(visibleChildren[visibleChildren.Count - 1] is Resizer); visibleChildren[visibleChildren.Count - 1].Measure(Size.Empty); visibleChildren.RemoveAt(visibleChildren.Count - 1); } @@ -237,7 +239,7 @@ namespace AvalonDock { i++; child = GetVisualChild(i) as FrameworkElement; - Debug.Assert(child is ResizingPanelSplitter); + Debug.Assert(child is Resizer); child.Measure(Size.Empty); } @@ -252,7 +254,9 @@ namespace AvalonDock if (visibleChildren.Count == 0) return new Size(); - Debug.Assert(!(visibleChildren.Last() is ResizingPanelSplitter)); + NormalizeStarLength(visibleChildren); + + Debug.Assert(!(visibleChildren.Last() is Resizer)); if (availableSize.Width == double.PositiveInfinity && Orientation == Orientation.Horizontal) @@ -281,23 +285,23 @@ namespace AvalonDock } var splitters = from FrameworkElement child in visibleChildren - where child is ResizingPanelSplitter + where child is Resizer select child; var childStars = from FrameworkElement child in visibleChildren - where (!(child is ResizingPanelSplitter)) && child.IsStar() + where (!(child is Resizer)) && child.IsStar() select child; var childAbsolutes = from FrameworkElement child in visibleChildren - where (!(child is ResizingPanelSplitter)) && child.IsAbsolute() + where (!(child is Resizer)) && child.IsAbsolute() select child; var childAutoSizes = from FrameworkElement child in visibleChildren - where (!(child is ResizingPanelSplitter)) && child.IsAuto() + where (!(child is Resizer)) && child.IsAuto() select child; //calculate the size of the splitters Size splitterSize = new Size(); - foreach (ResizingPanelSplitter splitter in splitters) + foreach (Resizer splitter in splitters) { splitterSize.Width += splitter.MinWidth; splitterSize.Height += splitter.MinHeight; @@ -355,7 +359,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) { child.Measure(new Size(child.MinWidth, availableSize.Height)); maxHeight = Math.Max(child.DesiredSize.Height, maxHeight); @@ -386,7 +390,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) { child.Measure(new Size(child.MinWidth, availableSize.Height)); maxHeight = Math.Max(child.DesiredSize.Height, maxHeight); @@ -440,7 +444,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) { child.Measure(new Size(availableSize.Width, child.MinHeight)); maxWidth = Math.Max(child.DesiredSize.Width, maxWidth); @@ -471,7 +475,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) { child.Measure(new Size(availableSize.Width, child.MinHeight)); maxWidth = Math.Max(child.DesiredSize.Width, maxWidth); @@ -506,6 +510,40 @@ namespace AvalonDock } } + private void NormalizeStarLength(IEnumerable visibleChildren) + { + var childrenWithStarLength = visibleChildren.Where(c => c is IDockableControl && c.IsStar()); + int childrenWithStartLengthCount = childrenWithStarLength.Count(); + + if (childrenWithStartLengthCount == 0) + return; + + if (childrenWithStartLengthCount == 1) + { + ResizingPanel.SetResizeWidth(childrenWithStarLength.First(), new GridLength(1.0, GridUnitType.Star)); + return; + } + + double sumStars = childrenWithStarLength.Sum(c => c.GetStarValue()); + + if (sumStars == 0) + { + //problem!?! try to fix... + childrenWithStarLength.ForEach(c => + { + ResizingPanel.SetResizeWidth(c, new GridLength(1.0 / childrenWithStartLengthCount, GridUnitType.Star)); + }); + } + else + { + childrenWithStarLength.ForEach(c => + { + ResizingPanel.SetResizeWidth(c, new GridLength(1.0 * c.GetStarValue() / sumStars, GridUnitType.Star)); + }); + } + + } + Size[] _childrenFinalSizes = null; /// @@ -515,6 +553,8 @@ namespace AvalonDock /// protected override Size ArrangeOverride(Size finalSize) { + //Debug.WriteLine("ResizingPanel.ArrangeOverride()"); + //Compute the list of visible children List visibleChildren = new List(); for (int i = 0; i < VisualChildrenCount; i++) @@ -531,13 +571,13 @@ namespace AvalonDock i > 0) { child = GetVisualChild(i - 1) as FrameworkElement; - Debug.Assert(child is ResizingPanelSplitter); + Debug.Assert(child is Resizer); child.Arrange(new Rect()); if (visibleChildren.Count > 0) { - Debug.Assert(visibleChildren[visibleChildren.Count - 1] is ResizingPanelSplitter); + Debug.Assert(visibleChildren[visibleChildren.Count - 1] is Resizer); visibleChildren[visibleChildren.Count - 1].Arrange(new Rect()); visibleChildren.RemoveAt(visibleChildren.Count - 1); } @@ -548,7 +588,7 @@ namespace AvalonDock i++; child = GetVisualChild(i) as FrameworkElement; child.Arrange(new Rect()); - Debug.Assert(child is ResizingPanelSplitter); + Debug.Assert(child is Resizer); } continue; @@ -564,29 +604,29 @@ namespace AvalonDock return new Size(); } - Debug.Assert(!(visibleChildren.Last() is ResizingPanelSplitter)); + Debug.Assert(!(visibleChildren.Last() is Resizer)); _childrenFinalSizes = new Size[visibleChildren.Count]; var splitters = from FrameworkElement child in visibleChildren - where child is ResizingPanelSplitter + where child is Resizer select child; var childStars = from FrameworkElement child in visibleChildren - where (!(child is ResizingPanelSplitter)) && child.IsStar() + where (!(child is Resizer)) && child.IsStar() select child; var childAbsolutes = from FrameworkElement child in visibleChildren - where (!(child is ResizingPanelSplitter)) && child.IsAbsolute() + where (!(child is Resizer)) && child.IsAbsolute() select child; var childAutoSizes = from FrameworkElement child in visibleChildren - where (!(child is ResizingPanelSplitter)) && child.IsAuto() + where (!(child is Resizer)) && child.IsAuto() select child; //calculate the size of the splitters Size splitterSize = new Size(); - foreach (ResizingPanelSplitter splitter in splitters) + foreach (Resizer splitter in splitters) { splitterSize.Width += splitter.MinWidth; splitterSize.Height += splitter.MinHeight; @@ -642,7 +682,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) _childrenFinalSizes[iChild++] = new Size(child.MinWidth, finalSize.Height); else if (child.IsAbsolute()) _childrenFinalSizes[iChild++] = new Size(Math.Max(child.GetAbsoluteValue() - delta, 0.0), finalSize.Height); @@ -661,7 +701,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) _childrenFinalSizes[iChild++] = new Size(child.MinWidth, finalSize.Height); else if (child.IsAbsolute()) _childrenFinalSizes[iChild++] = new Size(child.GetAbsoluteValue(), finalSize.Height); @@ -705,7 +745,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) _childrenFinalSizes[iChild++] = new Size(finalSize.Width, child.MinHeight); else if (child.IsAbsolute()) _childrenFinalSizes[iChild++] = new Size(finalSize.Width, Math.Max(child.GetAbsoluteValue() - delta, 0.0)); @@ -724,7 +764,7 @@ namespace AvalonDock foreach (FrameworkElement child in visibleChildren) { - if (child is ResizingPanelSplitter) + if (child is Resizer) _childrenFinalSizes[iChild++] = new Size(finalSize.Width, child.MinHeight); else if (child.IsAbsolute()) _childrenFinalSizes[iChild++] = new Size(finalSize.Width, child.GetAbsoluteValue()); @@ -755,7 +795,7 @@ namespace AvalonDock bool setupSplitters = false; bool splitterListIsDirty = false; - + void SetupSplitters() { if (!splitterListIsDirty) @@ -768,7 +808,7 @@ namespace AvalonDock while (_splitterList.Count > 0) { - ResizingPanelSplitter splitter = _splitterList[0]; + Resizer splitter = _splitterList[0]; splitter.DragStarted -= new DragStartedEventHandler(splitter_DragStarted); splitter.DragDelta -= new DragDeltaEventHandler(splitter_DragDelta); splitter.DragCompleted -= new DragCompletedEventHandler(splitter_DragCompleted); @@ -783,7 +823,8 @@ namespace AvalonDock { if (j == _splitterList.Count) { - ResizingPanelSplitter splitter = new ResizingPanelSplitter(); + Resizer splitter = new Resizer(); + splitter.Cursor = this.Orientation == Orientation.Horizontal ? Cursors.SizeWE : Cursors.SizeNS; _splitterList.Add(splitter); splitter.DragStarted += new DragStartedEventHandler(splitter_DragStarted); splitter.DragDelta += new DragDeltaEventHandler(splitter_DragDelta); @@ -797,8 +838,8 @@ namespace AvalonDock for (j = 0; j < _splitterList.Count; j++) { - _splitterList[j].Width = (Orientation == Orientation.Horizontal) ? 4 : double.NaN; - _splitterList[j].Height = (Orientation == Orientation.Vertical) ? 4 : double.NaN; + _splitterList[j].Width = (Orientation == Orientation.Horizontal) ? 6 : double.NaN; + _splitterList[j].Height = (Orientation == Orientation.Vertical) ? 6 : double.NaN; } #if DEBUG @@ -807,12 +848,12 @@ namespace AvalonDock while (Children.Count > 0) { Debug.Assert(Children[i] != null); - Debug.Assert(!(Children[i] is ResizingPanelSplitter)); + Debug.Assert(!(Children[i] is Resizer)); i++; if (i >= Children.Count) break; - Debug.Assert((Children[i] is ResizingPanelSplitter)); + Debug.Assert((Children[i] is Resizer)); i++; } @@ -828,10 +869,6 @@ namespace AvalonDock splitterListIsDirty = true; } - void splitter_DragCompleted(object sender, DragCompletedEventArgs e) - { - Cursor = Cursors.Arrow; - } /// /// This method is called by a splitter when it is dragged @@ -840,7 +877,253 @@ namespace AvalonDock /// void splitter_DragDelta(object sender, DragDeltaEventArgs e) { - ResizingPanelSplitter splitter = e.Source as ResizingPanelSplitter; + Resizer splitter = sender as Resizer; + + if (Orientation == System.Windows.Controls.Orientation.Horizontal) + { + Canvas.SetLeft(_resizerGhost, _initialStartPoint.X + e.HorizontalChange); + } + else + { + Canvas.SetTop(_resizerGhost, _initialStartPoint.Y + e.VerticalChange); + } + + + //ResizingPanelSplitter splitter = e.Source as ResizingPanelSplitter; + //int i = 0; + + ////Compute the list of visible children + //List visibleChildren = new List(); + //for (i = 0; i < VisualChildrenCount; i++) + //{ + // FrameworkElement child = GetVisualChild(i) as FrameworkElement; + + // IDockableControl dockableControl = child as IDockableControl; + // if (dockableControl != null && + // !dockableControl.IsDocked) + // { + // if (i == VisualChildrenCount - 1 && + // i > 0) + // { + // //remove the last splitter added + // if (visibleChildren.Count > 0 && + // visibleChildren.Last() is ResizingPanelSplitter) + // visibleChildren.RemoveAt(visibleChildren.Count - 1); + // } + // else if (i < VisualChildrenCount - 1) + // { + // //discard the next splitter + // i++; + // } + + // continue; + // } + + // visibleChildren.Add(child); + //} + + //if (visibleChildren.Count == 0) + // return; + + //if (visibleChildren.Last() is ResizingPanelSplitter) + // visibleChildren.RemoveAt(visibleChildren.Count - 1); + + //Size[] currentSizes = new Size[visibleChildren.Count]; + //double delta = Orientation == Orientation.Horizontal ? e.HorizontalChange : e.VerticalChange; + + //if (_childrenFinalSizes == null) + // return; + + //_childrenFinalSizes.CopyTo(currentSizes, 0); + + //int iSplitter = visibleChildren.IndexOf(splitter); + + //Debug.Assert(iSplitter > -1); + + //List prevChildren = new List(); + //for (i = iSplitter - 1; i >= 0; i--) + //{ + // FrameworkElement child = visibleChildren[i] as FrameworkElement; + // if (child is ResizingPanelSplitter) + // continue; + // if (child.IsAbsolute() || child.IsAuto()) + // { + // if (prevChildren.Count == 0) + // { + // prevChildren.Add(child); + // } + // break; + // } + // if (child.IsStar()) + // { + // prevChildren.Add(child); + // } + //} + + //List nextChildren = new List(); + + //for (i = iSplitter + 1; i < visibleChildren.Count; i++) + //{ + // FrameworkElement child = visibleChildren[i] as FrameworkElement; + // if (child is ResizingPanelSplitter) + // continue; + // if (child.IsAbsolute() || child.IsAuto()) + // { + // if (nextChildren.Count == 0) + // nextChildren.Add(child); + // break; + // } + // if (child.IsStar()) + // { + // nextChildren.Add(child); + // } + //} + + + //double prevMinSize = prevChildren.Sum(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight); + //double nextMinSize = nextChildren.Sum(c => Orientation == Orientation.Horizontal ? c.MinWidth : c.MinHeight); + //double prevMaxSize = prevChildren.Sum(c => Orientation == Orientation.Horizontal ? c.MaxWidth : c.MaxHeight); + //double nextMaxSize = nextChildren.Sum(c => Orientation == Orientation.Horizontal ? c.MaxWidth : c.MaxHeight); + + //double prevSize = prevChildren.Sum(c => Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width : currentSizes[visibleChildren.IndexOf(c)].Height); + //double nextSize = nextChildren.Sum(c => Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width : currentSizes[visibleChildren.IndexOf(c)].Height); + + //if (prevSize + delta < prevMinSize) + // delta = prevMinSize - prevSize; + //if (nextSize - delta < nextMinSize) + // delta = -(nextMinSize - nextSize); + + //double remDelta = delta * 2; + + //while (!HelperFunc.AreClose(delta, 0.0)) + //{ + // int prevChildrenCountWithNoMinLen = + // prevChildren.Count(c => delta > 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight)); + // int nextChildrenCountWithNoMinLen = + // nextChildren.Count(c => delta < 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight)); + + // delta = remDelta / 2.0; + + // for (i = 0; i < currentSizes.Length; i++) + // { + // FrameworkElement child = visibleChildren[i] as FrameworkElement; + // if (child is ResizingPanelSplitter) + // continue; + + // if (Orientation == Orientation.Horizontal) + // { + // if (prevChildren.Contains(child) && prevChildrenCountWithNoMinLen > 0) + // { + // double s = delta / prevChildrenCountWithNoMinLen; + // if (currentSizes[i].Width + s < child.MinWidth) + // s = child.MinWidth - currentSizes[i].Width; + + // currentSizes[i].Width += s; + // remDelta -= s; + // } + // if (nextChildren.Contains(child) && nextChildrenCountWithNoMinLen > 0) + // { + // double s = delta / nextChildrenCountWithNoMinLen; + // if (currentSizes[i].Width - s < child.MinWidth) + // s = currentSizes[i].Width - child.MinWidth; + + // currentSizes[i].Width -= s; + // remDelta -= s; + // } + // } + // else + // { + // if (prevChildren.Contains(child) && prevChildrenCountWithNoMinLen > 0) + // { + // double s = delta / prevChildrenCountWithNoMinLen; + // if (currentSizes[i].Height + s < child.MinHeight) + // s = child.MinHeight - currentSizes[i].Height; + + // currentSizes[i].Height += s; + // remDelta -= s; + // } + // if (nextChildren.Contains(child) && nextChildrenCountWithNoMinLen > 0) + // { + // double s = delta / nextChildrenCountWithNoMinLen; + // if (currentSizes[i].Height - s < child.MinHeight) + // s = currentSizes[i].Height - child.MinHeight; + + // currentSizes[i].Height -= s; + // remDelta -= s; + // } + // } + // } + //} + + //Debug.Assert(HelperFunc.AreClose(delta, 0.0)); + + //double totalStartsSum = 0.0; + //double totalSizeForStarts = 0.0; + + //for (i = 0; i < visibleChildren.Count; i++) + //{ + // FrameworkElement child = visibleChildren[i] as FrameworkElement; + // if (child is ResizingPanelSplitter) + // continue; + // if (child.IsStar()) + // { + // totalStartsSum += child.GetStarValue(); + // totalSizeForStarts += Orientation == Orientation.Horizontal ? currentSizes[i].Width : currentSizes[i].Height; + // } + //} + + + //double starsScaleFactor = totalStartsSum / totalSizeForStarts; + + //for (i = 0; i < currentSizes.Length; i++) + //{ + // FrameworkElement child = visibleChildren[i] as FrameworkElement; + + // if (child is ResizingPanelSplitter) + // continue; + + // if (child.IsStar()) + // { + // if (Orientation == Orientation.Horizontal) + // { + // SetResizeWidth(child, + // new GridLength(HelperFunc.MultiplyCheckNaN(currentSizes[i].Width, starsScaleFactor), GridUnitType.Star)); + // } + // else + // { + // SetResizeHeight(child, + // new GridLength(HelperFunc.MultiplyCheckNaN(currentSizes[i].Height, starsScaleFactor), GridUnitType.Star)); + // } + // } + // else if (child.IsAbsolute()) + // { + // if (Orientation == Orientation.Horizontal) + // { + // SetResizeWidth(child, + // new GridLength(currentSizes[i].Width, GridUnitType.Pixel)); + // } + // else + // { + // SetResizeHeight(child, + // new GridLength(currentSizes[i].Height, GridUnitType.Pixel)); + // } + // } + //} + + //InvalidateMeasure(); + } + + void splitter_DragStarted(object sender, DragStartedEventArgs e) + { + var resizer = sender as Resizer; + ShowResizerOverlayWindow(resizer); + } + + void splitter_DragCompleted(object sender, DragCompletedEventArgs e) + { + HideResizerOverlayWindow(); + + Resizer splitter = e.Source as Resizer; int i = 0; //Compute the list of visible children @@ -858,7 +1141,7 @@ namespace AvalonDock { //remove the last splitter added if (visibleChildren.Count > 0 && - visibleChildren.Last() is ResizingPanelSplitter) + visibleChildren.Last() is Resizer) visibleChildren.RemoveAt(visibleChildren.Count - 1); } else if (i < VisualChildrenCount - 1) @@ -876,7 +1159,7 @@ namespace AvalonDock if (visibleChildren.Count == 0) return; - if (visibleChildren.Last() is ResizingPanelSplitter) + if (visibleChildren.Last() is Resizer) visibleChildren.RemoveAt(visibleChildren.Count - 1); Size[] currentSizes = new Size[visibleChildren.Count]; @@ -895,7 +1178,7 @@ namespace AvalonDock for (i = iSplitter - 1; i >= 0; i--) { FrameworkElement child = visibleChildren[i] as FrameworkElement; - if (child is ResizingPanelSplitter) + if (child is Resizer) continue; if (child.IsAbsolute() || child.IsAuto()) { @@ -916,7 +1199,7 @@ namespace AvalonDock for (i = iSplitter + 1; i < visibleChildren.Count; i++) { FrameworkElement child = visibleChildren[i] as FrameworkElement; - if (child is ResizingPanelSplitter) + if (child is Resizer) continue; if (child.IsAbsolute() || child.IsAuto()) { @@ -952,13 +1235,13 @@ namespace AvalonDock prevChildren.Count(c => delta > 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight)); int nextChildrenCountWithNoMinLen = nextChildren.Count(c => delta < 0 ? true : (Orientation == Orientation.Horizontal ? currentSizes[visibleChildren.IndexOf(c)].Width > c.MinWidth : currentSizes[visibleChildren.IndexOf(c)].Height > c.MinHeight)); - + delta = remDelta / 2.0; for (i = 0; i < currentSizes.Length; i++) { FrameworkElement child = visibleChildren[i] as FrameworkElement; - if (child is ResizingPanelSplitter) + if (child is Resizer) continue; if (Orientation == Orientation.Horizontal) @@ -968,7 +1251,7 @@ namespace AvalonDock double s = delta / prevChildrenCountWithNoMinLen; if (currentSizes[i].Width + s < child.MinWidth) s = child.MinWidth - currentSizes[i].Width; - + currentSizes[i].Width += s; remDelta -= s; } @@ -1012,9 +1295,9 @@ namespace AvalonDock double totalSizeForStarts = 0.0; for (i = 0; i < visibleChildren.Count; i++) - { + { FrameworkElement child = visibleChildren[i] as FrameworkElement; - if (child is ResizingPanelSplitter) + if (child is Resizer) continue; if (child.IsStar()) { @@ -1022,7 +1305,6 @@ namespace AvalonDock totalSizeForStarts += Orientation == Orientation.Horizontal ? currentSizes[i].Width : currentSizes[i].Height; } } - double starsScaleFactor = totalStartsSum / totalSizeForStarts; @@ -1030,7 +1312,7 @@ namespace AvalonDock { FrameworkElement child = visibleChildren[i] as FrameworkElement; - if (child is ResizingPanelSplitter) + if (child is Resizer) continue; if (child.IsStar()) @@ -1056,103 +1338,84 @@ namespace AvalonDock else { SetResizeHeight(child, - new GridLength(currentSizes[i].Height, GridUnitType.Pixel)); + new GridLength(currentSizes[i].Height, GridUnitType.Pixel)); } } } InvalidateMeasure(); - - //ResizingPanelSplitter splitter = e.Source as ResizingPanelSplitter; - //int iSplitter = Children.IndexOf(splitter); - - //UIElement childPrev = null; - //UIElement childNext = null; - - ////int posInc = ResizingDirection == ResizingDirection.Direct ? 2 : -2; - //int posInc = 2;// FlowDirection == FlowDirection.LeftToRight ? 2 : -2; - //int negInc = -posInc; - //int i = iSplitter; - - //while (i >= 0 || - // i < Children.Count - 1) - //{ - // if (NextChildIsVisible(i)) - // { - // //childNext = Children[ResizingDirection == ResizingDirection.Direct ? i + 1 : i - 1]; - // childNext = Children[i + 1];//FlowDirection == FlowDirection.LeftToRight ? i + 1 : i - 1]; - // break; - // } - - // i += posInc; - //} - - //i = iSplitter; - - //while (i >= 0 || - // i < Children.Count - 1) - //{ - // if (PrevChildIsVisible(i)) - // { - // //childPrev = Children[ResizingDirection == ResizingDirection.Direct ? i - 1 : i + 1]; - // childPrev = Children[i - 1];//FlowDirection == FlowDirection.LeftToRight ? i - 1 : i + 1]; - // break; - // } - - // i -= posInc; - //} - - //Size resExtPrev = new Size((double)childPrev.GetValue(ResizeWidthProperty), (double)childPrev.GetValue(ResizeHeightProperty)); - //Size resExtNext = new Size((double)childNext.GetValue(ResizeWidthProperty), (double)childNext.GetValue(ResizeHeightProperty)); - - - //#region Orientation == Horizontal - //if (Orientation == Orientation.Horizontal) - //{ - // double delta = e.HorizontalChange; - - // if (!double.IsPositiveInfinity(resExtPrev.Width) && - // (resExtPrev.Width + delta < 0)) - // delta = -resExtPrev.Width; + } - // if (!double.IsPositiveInfinity(resExtNext.Width) && - // resExtNext.Width - delta < 0) - // delta = resExtNext.Width; + Border _resizerGhost = null; + Window _resizerWindowHost = null; + Vector _initialStartPoint; + void ShowResizerOverlayWindow(Resizer splitter) + { + Point ptTopLeftScreen = this.PointToScreen(new Point()); - // if (!double.IsPositiveInfinity(resExtPrev.Width)) - // childPrev.SetValue(ResizeWidthProperty, resExtPrev.Width + delta); - // if (!double.IsPositiveInfinity(resExtNext.Width)) - // childNext.SetValue(ResizeWidthProperty, resExtNext.Width - delta); - //} - //#endregion - //#region Orientation == Vertical - //else //if (Orientation == Orientation.Vertical) - //{ - // double delta = e.VerticalChange; + _resizerGhost = new Border() + { + Background = Brushes.Black, + Opacity = 0.7 + }; - // if (!double.IsPositiveInfinity(resExtPrev.Height) && - // (resExtPrev.Height + delta < 0)) - // delta = -resExtPrev.Height; + if (Orientation == System.Windows.Controls.Orientation.Horizontal) + { + _resizerGhost.Width = 5.0; + _resizerGhost.Height = ActualHeight; + } + else + { + _resizerGhost.Height = 5.0; + _resizerGhost.Width = ActualWidth; + } - // if (!double.IsPositiveInfinity(resExtNext.Height) && - // resExtNext.Height - delta < 0) - // delta = resExtNext.Height; + _initialStartPoint = splitter.PointToScreen(new Point()) - this.PointToScreen(new Point()); + if (Orientation == System.Windows.Controls.Orientation.Horizontal) + { + Canvas.SetLeft(_resizerGhost, _initialStartPoint.X); + } + else + { + Canvas.SetTop(_resizerGhost, _initialStartPoint.Y); + } - // if (!double.IsPositiveInfinity(resExtPrev.Height)) - // childPrev.SetValue(ResizeHeightProperty, resExtPrev.Height + delta); + Canvas panelHostResizer = new Canvas() + { + HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch, + VerticalAlignment = System.Windows.VerticalAlignment.Stretch + }; - // if (!double.IsPositiveInfinity(resExtNext.Height)) - // childNext.SetValue(ResizeHeightProperty, resExtNext.Height - delta); - //} - //#endregion + panelHostResizer.Children.Add(_resizerGhost); + _resizerWindowHost = new Window() + { + ResizeMode = ResizeMode.NoResize, + WindowStyle = System.Windows.WindowStyle.None, + ShowInTaskbar = false, + AllowsTransparency = true, + Background = null, + Width = ActualWidth, + Height = ActualHeight, + Left = ptTopLeftScreen.X, + Top = ptTopLeftScreen.Y, + ShowActivated = false, + Owner = Window.GetWindow(this), + Content = panelHostResizer + }; + + _resizerWindowHost.Show(); } - void splitter_DragStarted(object sender, DragStartedEventArgs e) + void HideResizerOverlayWindow() { - Cursor = Orientation == Orientation.Horizontal ? Cursors.SizeWE : Cursors.SizeNS; + if (_resizerWindowHost != null) + { + _resizerWindowHost.Close(); + _resizerWindowHost = null; + } } #region IDockableControl Membri di @@ -1253,8 +1516,12 @@ namespace AvalonDock next ? childRelativeIndex + 1 : childRelativeIndex, childToInsert); SetupSplitters(); + + InvalidateMeasure(); } + + } diff --git a/src/Libraries/AvalonDock/Resources/Brushes.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/Brushes.xaml similarity index 100% rename from src/Libraries/AvalonDock/Resources/Brushes.xaml rename to src/Libraries/AvalonDock/AvalonDock/Resources/Brushes.xaml diff --git a/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml new file mode 100644 index 0000000000..fb12dda598 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/Common.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/Resources/DockablePaneStyles.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml similarity index 81% rename from src/Libraries/AvalonDock/Resources/DockablePaneStyles.xaml rename to src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml index 467055b6db..e9db6e16b0 100644 --- a/src/Libraries/AvalonDock/Resources/DockablePaneStyles.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/DockablePaneStyles.xaml @@ -1,7 +1,9 @@  + xmlns:ad="clr-namespace:AvalonDock" + xmlns:adRes="clr-namespace:AvalonDock.Properties;assembly=AvalonDock" + > @@ -13,16 +15,17 @@ - - - - - + + + + + @@ -49,14 +52,7 @@ - - - + - - - - - \ No newline at end of file diff --git a/src/Libraries/AvalonDock/Resources/DockingManagerStyles.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/DockingManagerStyles.xaml similarity index 91% rename from src/Libraries/AvalonDock/Resources/DockingManagerStyles.xaml rename to src/Libraries/AvalonDock/AvalonDock/Resources/DockingManagerStyles.xaml index 30dfd9d484..3e6d163d67 100644 --- a/src/Libraries/AvalonDock/Resources/DockingManagerStyles.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/DockingManagerStyles.xaml @@ -9,7 +9,7 @@ - - - - - + - - + + + - - + + KeyboardNavigation.DirectionalNavigation="Contained"/> - - @@ -246,6 +195,9 @@ + + + diff --git a/src/Libraries/AvalonDock/Resources/FloatingWindowStyle.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/FloatingWindowStyle.xaml similarity index 78% rename from src/Libraries/AvalonDock/Resources/FloatingWindowStyle.xaml rename to src/Libraries/AvalonDock/AvalonDock/Resources/FloatingWindowStyle.xaml index 0d6b191279..dfd76b3d83 100644 --- a/src/Libraries/AvalonDock/Resources/FloatingWindowStyle.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/FloatingWindowStyle.xaml @@ -1,6 +1,10 @@ - + xmlns:primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=PresentationFramework" + xmlns:ad="clr-namespace:AvalonDock" + + > @@ -9,7 +13,7 @@ - - - + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Resources/NavigatorWindowStyle.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/NavigatorWindowStyle.xaml new file mode 100644 index 0000000000..66498a5123 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/NavigatorWindowStyle.xaml @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/Resources/OverlayWindowStyle.xaml b/src/Libraries/AvalonDock/AvalonDock/Resources/OverlayWindowStyle.xaml new file mode 100644 index 0000000000..501647c2c2 --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/Resources/OverlayWindowStyle.xaml @@ -0,0 +1,59 @@ + + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/AvalonDock/RoutedEventHandler.cs b/src/Libraries/AvalonDock/AvalonDock/RoutedEventHandler.cs new file mode 100644 index 0000000000..be35aed59e --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/RoutedEventHandler.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AvalonDock +{ + class RoutedEventHandler + { + } +} diff --git a/src/Libraries/AvalonDock/AvalonDock/RoutedEventHelper.cs b/src/Libraries/AvalonDock/AvalonDock/RoutedEventHelper.cs new file mode 100644 index 0000000000..97ee15f32b --- /dev/null +++ b/src/Libraries/AvalonDock/AvalonDock/RoutedEventHelper.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace AvalonDock +{ + using System; + using System.Windows; + + internal static class RoutedEventHelper + { + #region RoutedEvent Helper Methods + + /// + /// A static helper method to raise a routed event on a target UIElement or ContentElement. + /// + /// UIElement or ContentElement on which to raise the event + /// RoutedEventArgs to use when raising the event + internal static void RaiseEvent(DependencyObject target, RoutedEventArgs args) + { + if (target is UIElement) + { + (target as UIElement).RaiseEvent(args); + } + else if (target is ContentElement) + { + (target as ContentElement).RaiseEvent(args); + } + } + + /// + /// A static helper method that adds a handler for a routed event + /// to a target UIElement or ContentElement. + /// + /// UIElement or ContentElement that listens to the event + /// Event that will be handled + /// Event handler to be added + internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler) + { + UIElement uie = element as UIElement; + if (uie != null) + { + uie.AddHandler(routedEvent, handler); + } + else + { + ContentElement ce = element as ContentElement; + if (ce != null) + { + ce.AddHandler(routedEvent, handler); + } + } + } + + /// + /// A static helper method that removes a handler for a routed event + /// from a target UIElement or ContentElement. + /// + /// UIElement or ContentElement that listens to the event + /// Event that will no longer be handled + /// Event handler to be removed + internal static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler) + { + UIElement uie = element as UIElement; + if (uie != null) + { + uie.RemoveHandler(routedEvent, handler); + } + else + { + ContentElement ce = element as ContentElement; + if (ce != null) + { + ce.RemoveHandler(routedEvent, handler); + } + } + } + + #endregion + } +} diff --git a/src/Libraries/AvalonDock/ColorFactory.cs b/src/Libraries/AvalonDock/AvalonDock/ThemeFactory.cs similarity index 90% rename from src/Libraries/AvalonDock/ColorFactory.cs rename to src/Libraries/AvalonDock/AvalonDock/ThemeFactory.cs index bac0381de5..68f56aa2f4 100644 --- a/src/Libraries/AvalonDock/ColorFactory.cs +++ b/src/Libraries/AvalonDock/AvalonDock/ThemeFactory.cs @@ -1,5 +1,5 @@ //Copyright (c) 2009, Juergen Schildmann -//Copyright (c) 2007-2009, Adolfo Marinucci +//Copyright (c) 2007-2010, Adolfo Marinucci //All rights reserved. //Redistribution and use in source and binary forms, with or without modification, @@ -37,8 +37,9 @@ namespace AvalonDock /// /// Is used for color-support to change the colors depending on a base theme. /// - public sealed class ColorFactory + public sealed class ThemeFactory { + /// /// Change the theme to one from AvalonDock. /// /// for example: "aero.normalcolor" (default style) @@ -48,7 +49,22 @@ namespace AvalonDock rd.Source = new Uri("/AvalonDock;component/themes/" + theme + ".xaml", UriKind.RelativeOrAbsolute); // first search and remove old one - ResetColors(); + ResetTheme(); + + Application.Current.Resources.MergedDictionaries.Add(rd); + } + + /// + /// Change the theme to one from AvalonDock. + /// + /// for example: /AvalonDock;component/themes/aero.normalcolor.xaml" (default style) + public static void ChangeTheme(Uri themeUri) + { + ResourceDictionary rd = new ResourceDictionary(); + rd.Source = themeUri; + + // first search and remove old one + ResetTheme(); Application.Current.Resources.MergedDictionaries.Add(rd); } @@ -84,18 +100,7 @@ namespace AvalonDock ChangeKeysInResourceDictionary(rd2, color); } - //ResourceDictionary parent = Application.Current.Resources; - // first search and remove old one - //foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries) - //{ - // string source = res.Source.ToString(); - // if (source.Contains("/AvalonDock;component/themes/")) - // { - // Application.Current.Resources.MergedDictionaries.Remove(res); - // break; - // } - //} - ResetColors(); + ResetTheme(); Application.Current.Resources.MergedDictionaries.Add(rd); } @@ -103,7 +108,7 @@ namespace AvalonDock /// /// Reset custom colors to theme defaults /// - public static void ResetColors() + public static void ResetTheme() { //- foreach (ResourceDictionary res in Application.Current.Resources.MergedDictionaries) ResourceDictionary res = GetActualResourceDictionary(); @@ -170,18 +175,6 @@ namespace AvalonDock } } - - // { - // string source = res.Source.ToString(); - // if (source.Contains("/AvalonDock;component/themes/")) - // { - // Application.Current.Resources.MergedDictionaries.Remove(res); - // break; - // } - // } - //} - - /// /// Searches for keys in the ResourceDictionary for brushes and changes the color-values /// @@ -225,7 +218,8 @@ namespace AvalonDock if (res.Source != null) { string source = res.Source.ToString(); - if (source.Contains("/AvalonDock;component/themes/")) + if (source.Contains("/AvalonDock;component/themes/") || + source.Contains("/AvalonDock.Themes;component/themes/")) { return res; } diff --git a/src/Libraries/AvalonDock/themes/aero.normalcolor.brushes.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.brushes.xaml similarity index 96% rename from src/Libraries/AvalonDock/themes/aero.normalcolor.brushes.xaml rename to src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.brushes.xaml index 673e70395e..5df899546d 100644 --- a/src/Libraries/AvalonDock/themes/aero.normalcolor.brushes.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.brushes.xaml @@ -1,4 +1,4 @@ - @@ -148,7 +148,7 @@ Color="#FFC1D2EE"/> \ No newline at end of file diff --git a/src/Libraries/AvalonDock/themes/aero.normalcolor.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml similarity index 62% rename from src/Libraries/AvalonDock/themes/aero.normalcolor.xaml rename to src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml index e1bdd0dc5f..5db743fc14 100644 --- a/src/Libraries/AvalonDock/themes/aero.normalcolor.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/aero.normalcolor.xaml @@ -1,7 +1,9 @@  + xmlns:ad="clr-namespace:AvalonDock" + xmlns:adRes="clr-namespace:AvalonDock.Properties;assembly=AvalonDock" + > @@ -35,15 +37,8 @@ - - - - + - - - + + + - + - + + + + + + + + + - - - - - - + + + + + + + + + - - - - - \ No newline at end of file diff --git a/src/Libraries/AvalonDock/themes/classic.brushes.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/classic.brushes.xaml similarity index 95% rename from src/Libraries/AvalonDock/themes/classic.brushes.xaml rename to src/Libraries/AvalonDock/AvalonDock/Themes/classic.brushes.xaml index 45b2989ca3..059c9d440e 100644 --- a/src/Libraries/AvalonDock/themes/classic.brushes.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/classic.brushes.xaml @@ -96,5 +96,9 @@ x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundMouseOver}}" Color="#FFFCFBFB"/> + + \ No newline at end of file diff --git a/src/Libraries/AvalonDock/themes/classic.xaml b/src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml similarity index 65% rename from src/Libraries/AvalonDock/themes/classic.xaml rename to src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml index b925e76c86..74cd47ba02 100644 --- a/src/Libraries/AvalonDock/themes/classic.xaml +++ b/src/Libraries/AvalonDock/AvalonDock/Themes/classic.xaml @@ -2,6 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock"> + @@ -29,14 +30,7 @@ - - - + - - - + - - + + + + + + + + + - - - - - - + + + + + + + + + - - - - - \ No newline at end of file diff --git a/src/Libraries/AvalonDock/Resources/NavigatorWindowStyle.xaml b/src/Libraries/AvalonDock/Resources/NavigatorWindowStyle.xaml deleted file mode 100644 index f8433a0e02..0000000000 --- a/src/Libraries/AvalonDock/Resources/NavigatorWindowStyle.xaml +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Libraries/AvalonDock/Resources/OverlayWindowStyle.xaml b/src/Libraries/AvalonDock/Resources/OverlayWindowStyle.xaml deleted file mode 100644 index b26979c92e..0000000000 --- a/src/Libraries/AvalonDock/Resources/OverlayWindowStyle.xaml +++ /dev/null @@ -1,58 +0,0 @@ - - - \ No newline at end of file diff --git a/src/Libraries/AvalonDock/WindowInteropWrapper.cs b/src/Libraries/AvalonDock/WindowInteropWrapper.cs deleted file mode 100644 index b02519263d..0000000000 --- a/src/Libraries/AvalonDock/WindowInteropWrapper.cs +++ /dev/null @@ -1,146 +0,0 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci -//All rights reserved. - -//Redistribution and use in source and binary forms, with or without modification, -//are permitted provided that the following conditions are met: -// -//* Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -//* Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -//* Neither the name of Adolfo Marinucci nor the names of its contributors may -// be used to endorse or promote products derived from this software without -// specific prior written permission. -// -//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows; -using System.Windows.Interop; -using System.Runtime.InteropServices; -using System.Diagnostics; - -namespace AvalonDock -{ - class WindowInteropWrapper : IDisposable - { - public WindowInteropWrapper() - { - } - - DependencyObject _attachedObject; - - public DependencyObject AttachedObject - { - get {return _attachedObject;} - set - { - if (_attachedObject != value) - { - if (_attachedObject != null) - { - _hwndSrc.RemoveHook(_hwndSrcHook); - //_hwndSrc.Dispose(); - _hwndSrc = null; - _hwndSrcHook = null; - } - - _attachedObject = value; - - if (_attachedObject != null) - { - _hwndSrc = HwndSource.FromDependencyObject(value) as HwndSource; - _hwndSrcHook = new HwndSourceHook(this.HookHandler); - _hwndSrc.AddHook(_hwndSrcHook); - } - } - } - } - - HwndSource _hwndSrc = null; - HwndSourceHook _hwndSrcHook = null; - - #region interop funtions and consts - const int WM_NCACTIVATE = 0x86; - const int WM_ACTIVATEAPP = 0x1c; - const int WM_ACTIVATE = 6; - const int WM_WINDOWPOSCHANGING = 70; - const int WM_WINDOWPOSCHANGED = 0x47; - const int WM_MOVE = 0x0003; - const int WM_SIZE = 0x0005; - const int WM_NCMOUSEMOVE = 0xa0; - const int WM_NCLBUTTONDOWN = 0xA1; - const int WM_NCLBUTTONUP = 0xA2; - const int WM_NCLBUTTONDBLCLK = 0xA3; - const int WM_NCRBUTTONDOWN = 0xA4; - const int WM_NCRBUTTONUP = 0xA5; - const int HTCAPTION = 2; - const int SC_MOVE = 0xF010; - const int WM_SYSCOMMAND = 0x0112; - - - [DllImport("user32.dll", CharSet = CharSet.Auto)] - public static extern IntPtr SendMessage(HandleRef hWnd, int msg, IntPtr wParam, IntPtr lParam); - - [DllImport("user32.dll")] - public static extern bool LockWindowUpdate(IntPtr hWndLock); - - #endregion - - private IntPtr HookHandler( - IntPtr hwnd, - int msg, - IntPtr wParam, - IntPtr lParam, - ref bool handled - ) - { - handled = false; - - switch (msg) - { - case SC_MOVE: - case WM_WINDOWPOSCHANGING: - SafeFireEvent(OnWindowPosChanging, EventArgs.Empty); - break; - } - - return IntPtr.Zero; - } - - public event EventHandler OnWindowPosChanging; - - - void SafeFireEvent(EventHandler eventToFireup, EventArgs e) - { - if (AttachedObject != null && - PresentationSource.FromDependencyObject(AttachedObject) != null) - { - if (eventToFireup != null) - eventToFireup(this, e); - } - } - - - #region IDisposable Members - - public void Dispose() - { - AttachedObject = null; - GC.SuppressFinalize(this); - } - - #endregion - } -} diff --git a/src/Libraries/AvalonDock/WpfApplication.cs b/src/Libraries/AvalonDock/WpfApplication.cs deleted file mode 100644 index 193b970f45..0000000000 --- a/src/Libraries/AvalonDock/WpfApplication.cs +++ /dev/null @@ -1,96 +0,0 @@ -//Copyright (c) 2007-2009, Adolfo Marinucci -//All rights reserved. - -//Redistribution and use in source and binary forms, with or without modification, -//are permitted provided that the following conditions are met: -// -//* Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -//* Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -//* Neither the name of Adolfo Marinucci nor the names of its contributors may -// be used to endorse or promote products derived from this software without -// specific prior written permission. -// -//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -//AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -//IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -//PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -//HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -//OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -//EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -using System; -using System.Windows; -using System.Windows.Threading; - - - -namespace AvalonDock -{ - - /// - /// Designates a Windows Presentation Foundation application model with added functionalities. - /// - class WpfApplication : Application - { - - private static DispatcherOperationCallback exitFrameCallback = new - DispatcherOperationCallback(ExitFrame); - - - - /// - /// Processes all UI messages currently in the message queue. - /// - public static void DoEvents() - { - - // Create new nested message pump. - DispatcherFrame nestedFrame = new DispatcherFrame(); - - - - // Dispatch a callback to the current message queue, when getting called, - // this callback will end the nested message loop. - // note that the priority of this callback should be lower than the that of UI event messages. - DispatcherOperation exitOperation = Dispatcher.CurrentDispatcher.BeginInvoke( - DispatcherPriority.Background, exitFrameCallback, nestedFrame); - - - - // pump the nested message loop, the nested message loop will - // immediately process the messages left inside the message queue. - Dispatcher.PushFrame(nestedFrame); - - - - // If the "exitFrame" callback doesn't get finished, Abort it. - if (exitOperation.Status != DispatcherOperationStatus.Completed) - { - exitOperation.Abort(); - } - - } - - - - private static Object ExitFrame(Object state) - { - DispatcherFrame frame = state as DispatcherFrame; - - - // Exit the nested message loop. - frame.Continue = false; - - return null; - - } - - } - -} - diff --git a/src/Libraries/AvalonDock/doc/AvalonDock.shfb b/src/Libraries/AvalonDock/doc/AvalonDock.shfb deleted file mode 100644 index 23e6041ab1..0000000000 --- a/src/Libraries/AvalonDock/doc/AvalonDock.shfb +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - Summary, Parameter, Returns, AutoDocumentCtors, Namespace, TypeParameter - InheritedMembers, InheritedFrameworkMembers, Protected, SealedProtected - - - .\Help\ - - - True - True - - HtmlHelp1x - False - 3.5 - False - False - False - - AvalonDock Library Documentation - AvalonDock - en-US - http://www.codeplex.com/AvalonDock/license - (C)2008 Adolfo Marinucci - - - - - Local - Msdn - Blank - Prototype - Guid - Standard - False - True - False - Hierarchical - True - ms.vsipcc+, ms.vsexpresscc+ - 1.0.0.0 - AboveNamespaces - \ No newline at end of file diff --git a/src/Libraries/AvalonDock/themes/classic2.xaml b/src/Libraries/AvalonDock/themes/classic2.xaml deleted file mode 100644 index 9f17426088..0000000000 --- a/src/Libraries/AvalonDock/themes/classic2.xaml +++ /dev/null @@ -1,548 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs index 7d65321831..63a227dfee 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.cs @@ -38,6 +38,22 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion set { isFiltering = value; } } + /// + /// Dependency property for . + /// + public static readonly DependencyProperty EmptyTemplateProperty = + DependencyProperty.Register("EmptyTemplate", typeof(ControlTemplate), typeof(CompletionList), + new FrameworkPropertyMetadata()); + + /// + /// Content of EmptyTemplate will be shown when CompletionList contains no items. + /// If EmptyTemplate is null, nothing will be shown. + /// + public ControlTemplate EmptyTemplate { + get { return (ControlTemplate)GetValue(EmptyTemplateProperty); } + set { SetValue(EmptyTemplateProperty, value); } + } + /// /// Is raised when the completion list indicates that the user has chosen /// an entry to be completed. @@ -337,7 +353,7 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion return -1; } - bool CamelCaseMatch(string text, string query) + static bool CamelCaseMatch(string text, string query) { int i = 0; foreach (char upper in text.Where(c => char.IsUpper(c))) { diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.xaml b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.xaml index f04c7e814f..ee9753becc 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.xaml +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionList.xaml @@ -38,7 +38,8 @@ - + diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs index c3f6d3528f..2f4f3792d2 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindow.cs @@ -10,9 +10,9 @@ using System.Diagnostics; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; +using System.Windows.Data; using System.Windows.Input; using System.Windows.Threading; - using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; @@ -26,6 +26,13 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion readonly CompletionList completionList = new CompletionList(); ToolTip toolTip = new ToolTip(); + /// + /// Gets the completion list used in this completion window. + /// + public CompletionList CompletionList { + get { return completionList; } + } + /// /// Creates a new code completion window. /// @@ -181,12 +188,5 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion } } } - - /// - /// Gets the completion list used in this completion window. - /// - public CompletionList CompletionList { - get { return completionList; } - } } } \ No newline at end of file diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs index 6c56227950..10ee097ab6 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/CodeCompletion/CompletionWindowBase.cs @@ -38,8 +38,18 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion Window parentWindow; TextDocument document; - int startOffset; - int endOffset; + + /// + /// Gets/Sets the start of the text range in which the completion window stays open. + /// This text portion is used to determine the text used to select an entry in the completion list by typing. + /// + public int StartOffset { get; set; } + + /// + /// Gets/Sets the end of the text range in which the completion window stays open. + /// This text portion is used to determine the text used to select an entry in the completion list by typing. + /// + public int EndOffset { get; set; } /// /// Creates a new CompletionWindowBase. @@ -53,7 +63,7 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion this.Owner = parentWindow; this.AddHandler(MouseUpEvent, new MouseButtonEventHandler(OnMouseUp), true); - startOffset = endOffset = this.TextArea.Caret.Offset; + StartOffset = EndOffset = this.TextArea.Caret.Offset; AttachEvents(); } @@ -312,24 +322,6 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion this.Top = bounds.Y; } - /// - /// Gets/Sets the start of the text range in which the completion window stays open. - /// This text portion is used to determine the text used to select an entry in the completion list by typing. - /// - public int StartOffset { - get { return startOffset; } - set { startOffset = value; } - } - - /// - /// Gets/Sets the end of the text range in which the completion window stays open. - /// This text portion is used to determine the text used to select an entry in the completion list by typing. - /// - public int EndOffset { - get { return endOffset; } - set { endOffset = value; } - } - /// /// Gets/sets whether the completion window should expect text insertion at the start offset, /// which not go into the completion region, but before it. @@ -344,13 +336,13 @@ namespace ICSharpCode.AvalonEdit.CodeCompletion Close(); // removal immediately in front of completion segment: close the window // this is necessary when pressing backspace after dot-completion } - if (e.Offset == startOffset && e.RemovalLength == 0 && ExpectInsertionBeforeStart) { - startOffset = e.GetNewOffset(startOffset, AnchorMovementType.AfterInsertion); + if (e.Offset == StartOffset && e.RemovalLength == 0 && ExpectInsertionBeforeStart) { + StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.AfterInsertion); this.ExpectInsertionBeforeStart = false; } else { - startOffset = e.GetNewOffset(startOffset, AnchorMovementType.BeforeInsertion); + StartOffset = e.GetNewOffset(StartOffset, AnchorMovementType.BeforeInsertion); } - endOffset = e.GetNewOffset(endOffset, AnchorMovementType.AfterInsertion); + EndOffset = e.GetNewOffset(EndOffset, AnchorMovementType.AfterInsertion); } } } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs index 01136854d5..1f63816335 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Document/TextDocument.cs @@ -142,14 +142,6 @@ namespace ICSharpCode.AvalonEdit.Document return rope[offset]; } -// /// -// /// Like GetCharAt, but without any safety checks. -// /// -// internal char FastGetCharAt(int offset) -// { -// return textBuffer.GetCharAt(offset); -// } - WeakReference cachedText; /// diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs index 1b3f3c2609..4399f98364 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Editing/Caret.cs @@ -352,6 +352,19 @@ namespace ICSharpCode.AvalonEdit.Editing lineBottom - lineTop); } + /// + /// Returns the caret rectangle. The coordinate system is in device-independent pixels from the top of the document. + /// + public Rect CalculateCaretRectangle() + { + if (textView != null && textView.Document != null) { + VisualLine visualLine = textView.GetOrConstructVisualLine(textView.Document.GetLineByNumber(position.Line)); + return CalcCaretRectangle(visualLine); + } else { + return Rect.Empty; + } + } + /// /// Minimum distance of the caret to the view border. /// @@ -367,9 +380,8 @@ namespace ICSharpCode.AvalonEdit.Editing internal void BringCaretToView(double border) { - if (textView != null && textView.Document != null) { - VisualLine visualLine = textView.GetOrConstructVisualLine(textView.Document.GetLineByNumber(position.Line)); - Rect caretRectangle = CalcCaretRectangle(visualLine); + Rect caretRectangle = CalculateCaretRectangle(); + if (!caretRectangle.IsEmpty) { caretRectangle.Inflate(border, border); textView.MakeVisible(caretRectangle); } diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/XmlFoldingStrategy.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/XmlFoldingStrategy.cs index 82562b0ddf..87123a0e6c 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/XmlFoldingStrategy.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Folding/XmlFoldingStrategy.cs @@ -78,8 +78,11 @@ namespace ICSharpCode.AvalonEdit.Folding } firstErrorOffset = -1; } catch (XmlException ex) { - // ignore errors - firstErrorOffset = document.GetOffset(ex.LineNumber, ex.LinePosition); + // ignore errors at invalid positions (prevent ArgumentOutOfRangeException) + if (ex.LineNumber >= 1 && ex.LineNumber <= document.LineCount) + firstErrorOffset = document.GetOffset(ex.LineNumber, ex.LinePosition); + else + firstErrorOffset = 0; } foldMarkers.Sort((a,b) => a.StartOffset.CompareTo(b.StartOffset)); return foldMarkers; diff --git a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs index db775e9de7..e125927630 100644 --- a/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs +++ b/src/Libraries/AvalonEdit/ICSharpCode.AvalonEdit/Utils/Rope.cs @@ -100,7 +100,7 @@ namespace ICSharpCode.AvalonEdit.Utils /// Any modifications inside the rope will also cause the content to be initialized. /// However, insertions at the beginning and the end, as well as inserting this rope into another or /// using the method, allows constructions of larger ropes where parts are - /// lazyly loaded. + /// lazily loaded. /// However, even methods like Concat may sometimes cause the initializer function to be called, e.g. when /// two short ropes are concatenated. /// @@ -451,7 +451,8 @@ namespace ICSharpCode.AvalonEdit.Utils /// public T this[int index] { get { - if (index < 0 || index >= this.Length) { + // use unsigned integers - this way negative values for index overflow and can be tested for with the same check + if (unchecked((uint)index >= (uint)this.Length)) { throw new ArgumentOutOfRangeException("index", index, "0 <= index < " + this.Length.ToString(CultureInfo.InvariantCulture)); } RopeCacheEntry entry = FindNodeUsingCache(index).Peek(); diff --git a/src/Libraries/GraphSharp/GraphSharp.Contracts.dll b/src/Libraries/GraphSharp/GraphSharp.Contracts.dll new file mode 100644 index 0000000000..3bc529c29d Binary files /dev/null and b/src/Libraries/GraphSharp/GraphSharp.Contracts.dll differ diff --git a/src/Libraries/GraphSharp/GraphSharp.Controls.dll b/src/Libraries/GraphSharp/GraphSharp.Controls.dll new file mode 100644 index 0000000000..45b1b7feed Binary files /dev/null and b/src/Libraries/GraphSharp/GraphSharp.Controls.dll differ diff --git a/src/Libraries/GraphSharp/GraphSharp.dll b/src/Libraries/GraphSharp/GraphSharp.dll new file mode 100644 index 0000000000..8b73c76a46 Binary files /dev/null and b/src/Libraries/GraphSharp/GraphSharp.dll differ diff --git a/src/Libraries/GraphSharp/Microsoft.Contracts.dll b/src/Libraries/GraphSharp/Microsoft.Contracts.dll new file mode 100644 index 0000000000..1eff269c6a Binary files /dev/null and b/src/Libraries/GraphSharp/Microsoft.Contracts.dll differ diff --git a/src/Libraries/GraphSharp/QuickGraph.dll b/src/Libraries/GraphSharp/QuickGraph.dll new file mode 100644 index 0000000000..2f2f34a848 Binary files /dev/null and b/src/Libraries/GraphSharp/QuickGraph.dll differ diff --git a/src/Libraries/GraphSharp/WPFExtensions.dll b/src/Libraries/GraphSharp/WPFExtensions.dll new file mode 100644 index 0000000000..b617dc4fc0 Binary files /dev/null and b/src/Libraries/GraphSharp/WPFExtensions.dll differ diff --git a/src/Libraries/ICSharpCode.Build.Tasks/Project/CopyLocalWorkaround.cs b/src/Libraries/ICSharpCode.Build.Tasks/Project/CopyLocalWorkaround.cs index 06d421de2b..7a44ea9f97 100644 --- a/src/Libraries/ICSharpCode.Build.Tasks/Project/CopyLocalWorkaround.cs +++ b/src/Libraries/ICSharpCode.Build.Tasks/Project/CopyLocalWorkaround.cs @@ -23,7 +23,6 @@ namespace ICSharpCode.Build.Tasks [Output] public ITaskItem[] OutputAssemblies { get; set; } - public ITaskItem[] AssemblyFiles { get; set; } [Output] @@ -31,36 +30,40 @@ namespace ICSharpCode.Build.Tasks public override bool Execute() { - // mark known assemblies as copy local=false - List outputAssemblies = new List(); - foreach (ITaskItem item in this.Assemblies) { - if (string.IsNullOrEmpty(item.GetMetadata("Private"))) { - string assemblyName = item.ItemSpec; - foreach (string knownAssembly in KnownFrameworkAssemblies.FullAssemblyNames) { - if (knownAssembly.StartsWith(assemblyName, StringComparison.OrdinalIgnoreCase)) { - if (assemblyName.IndexOf(',') >= 0 || knownAssembly.IndexOf(',') == assemblyName.Length) { - // either matching full name, or matching short name - item.SetMetadata("Private", "False"); - outputAssemblies.Add(item); - break; + if (this.Assemblies != null) { + // mark known assemblies as copy local=false + List outputAssemblies = new List(); + foreach (ITaskItem item in this.Assemblies) { + if (string.IsNullOrEmpty(item.GetMetadata("Private"))) { + string assemblyName = item.ItemSpec; + foreach (string knownAssembly in KnownFrameworkAssemblies.FullAssemblyNames) { + if (knownAssembly.StartsWith(assemblyName, StringComparison.OrdinalIgnoreCase)) { + if (assemblyName.IndexOf(',') >= 0 || knownAssembly.IndexOf(',') == assemblyName.Length) { + // either matching full name, or matching short name + item.SetMetadata("Private", "False"); + outputAssemblies.Add(item); + break; + } } } } } + this.OutputAssemblies = outputAssemblies.ToArray(); } - this.OutputAssemblies = outputAssemblies.ToArray(); - // mark mscorlib as copy local=false - List outputAssemblyFiles = new List(); - foreach (ITaskItem item in this.AssemblyFiles) { - if (string.IsNullOrEmpty(item.GetMetadata("Private"))) { - if (item.ItemSpec.EndsWith("\\mscorlib.dll", StringComparison.OrdinalIgnoreCase)) { - item.SetMetadata("Private", "False"); - outputAssemblyFiles.Add(item); + if (this.AssemblyFiles != null) { + // mark mscorlib as copy local=false + List outputAssemblyFiles = new List(); + foreach (ITaskItem item in this.AssemblyFiles) { + if (string.IsNullOrEmpty(item.GetMetadata("Private"))) { + if (item.ItemSpec.EndsWith("\\mscorlib.dll", StringComparison.OrdinalIgnoreCase)) { + item.SetMetadata("Private", "False"); + outputAssemblyFiles.Add(item); + } } } + this.OutputAssemblyFiles = outputAssemblyFiles.ToArray(); } - this.OutputAssemblyFiles = outputAssemblyFiles.ToArray(); return true; } } diff --git a/src/Libraries/Mono.Cecil/Mono.Cecil.dll b/src/Libraries/Mono.Cecil/Mono.Cecil.dll index b0609134d2..a64d7c7edf 100755 Binary files a/src/Libraries/Mono.Cecil/Mono.Cecil.dll and b/src/Libraries/Mono.Cecil/Mono.Cecil.dll differ diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 51581ee030..434416b763 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -92,6 +92,7 @@ + @@ -268,6 +269,7 @@ + @@ -770,14 +772,15 @@ - + {2FF700C2-A38A-48BD-A637-8CAFD4FE6237} AvalonDock + False {6C55B776-26D4-4DB3-A6AB-87E783B2F3D1} ICSharpCode.AvalonEdit - True + False {2D18BE89-D210-49EB-A9DD-2246FBB3DF6D} @@ -787,6 +790,7 @@ {3A9AE6AA-BC07-4A2F-972C-581E3AE2F195} NRefactory + False {35cef10f-2d4c-45f2-9dd1-161e0fec583c} diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs index 5108610f1c..c262b88842 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/CodeCompletionItemProvider.cs @@ -11,8 +11,8 @@ using System.Collections.Generic; using System.Text; using System.Text.RegularExpressions; using System.Xml; - using ICSharpCode.Core; +using ICSharpCode.NRefactory; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Project.Converter; using ICSharpCode.SharpDevelop.Refactoring; @@ -49,6 +49,11 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion /// public class CodeCompletionItemProvider : AbstractCompletionItemProvider { + /// + /// Gets/Sets whether items from all namespaces should be included in code completion, regardless of imports. + /// + public virtual bool ShowItemsFromAllNamespaces { get; set; } + /// public override ICompletionItemList GenerateCompletionList(ITextEditor editor) { @@ -103,12 +108,14 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion if (rr == null) return null; IProjectContent callingContent = rr.CallingClass != null ? rr.CallingClass.ProjectContent : null; - List arr = rr.GetCompletionData(callingContent ?? ParserService.CurrentProjectContent); + List arr = rr.GetCompletionData(callingContent ?? ParserService.CurrentProjectContent, this.ShowItemsFromAllNamespaces); return GenerateCompletionListForCompletionData(arr, context); } protected virtual DefaultCompletionItemList CreateCompletionItemList() { + // This is overriden in DotCodeCompletionItemProvider (C# and VB dot completion) + // and NRefactoryCtrlSpaceCompletionItemProvider (C# and VB Ctrl+Space completion) return new DefaultCompletionItemList(); } @@ -179,7 +186,10 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion public class DotCodeCompletionItemProvider : CodeCompletionItemProvider { - + protected override DefaultCompletionItemList CreateCompletionItemList() + { + return new NRefactoryCompletionItemList() { ContainsItemsFromAllNamespaces = this.ShowItemsFromAllNamespaces }; + } } sealed class KeywordCompletionItem : DefaultCompletionItem @@ -277,8 +287,17 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion insertedText = selectedClass.FullyQualifiedName; } } else { - // The name is unknown - we add a using + // The name is unknown - add a using addUsing = true; + if ((this.Entity is IClass) && (context.StartOffset > 0) && (document.GetCharAt(context.StartOffset - 1) == '.')) { + // But don't add using if user is typing qualified type name (e.g. System.IO.) + addUsing = false; + } + } + + // Special case for Attributes + if (insertedText.EndsWith("Attribute") && IsInAttributeContext(editor, context.StartOffset)) { + insertedText = insertedText.RemoveEnd("Attribute"); } // Insert the text @@ -297,6 +316,20 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion } } + /// + /// Returns true if the offset where we are inserting is in Attibute context, that is [*expr* + /// + bool IsInAttributeContext(ITextEditor editor, int offset) + { + if (editor == null || editor.Document == null) + return false; + var expressionFinder = ParserService.GetExpressionFinder(editor.FileName); + if (expressionFinder == null) + return false; + var resolvedExpression = expressionFinder.FindFullExpression(editor.Document.Text, offset); + return resolvedExpression.Context == ExpressionContext.Attribute; + } + #region Description string description; bool descriptionCreated; diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/CtrlSpaceCompletionItemProvider.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/CtrlSpaceCompletionItemProvider.cs index e454b67499..782bebef1c 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/CtrlSpaceCompletionItemProvider.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/CtrlSpaceCompletionItemProvider.cs @@ -27,17 +27,12 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion ExpressionContext overrideContext; - bool allowCompleteExistingExpression; - /// /// Gets/Sets whether completing an old expression is allowed. /// You have to set this property to true to let the provider run FindExpression, when /// set to false it will use ExpressionContext.Default (unless the constructor with "overrideContext" was used). /// - public bool AllowCompleteExistingExpression { - get { return allowCompleteExistingExpression; } - set { allowCompleteExistingExpression = value; } - } + public bool AllowCompleteExistingExpression { get; set; } /// /// Gets/Sets whether code templates should be included in code completion. @@ -67,7 +62,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion ICompletionItemList GenerateCompletionListCore(ITextEditor editor) { preselectionLength = 0; - if (!allowCompleteExistingExpression) { + if (!AllowCompleteExistingExpression) { ExpressionContext context = overrideContext ?? ExpressionContext.Default; var ctrlSpace = CtrlSpace(editor, context); return GenerateCompletionListForCompletionData(ctrlSpace, context); @@ -121,6 +116,11 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion this.language = language; } + protected override DefaultCompletionItemList CreateCompletionItemList() + { + return new NRefactoryCompletionItemList() { ContainsItemsFromAllNamespaces = this.ShowItemsFromAllNamespaces }; + } + protected override List CtrlSpace(ITextEditor editor, ExpressionContext context) { var resolver = new Dom.NRefactoryResolver.NRefactoryResolver(language); @@ -128,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion editor.Caret.Line, editor.Caret.Column, ParserService.GetParseInformation(editor.FileName), editor.Document.Text, - context); + context, this.ShowItemsFromAllNamespaces); } } } diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs index 2e1060b516..c0183e95a2 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/ICompletionItemList.cs @@ -34,6 +34,13 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion /// CompletionItemListKeyResult ProcessInput(char key); + /// + /// True if this list contains all items that were available. + /// False if this list could contain even more items + /// (e.g. by including items from all referenced projects, regardless of imports). + /// + bool ContainsAllAvailableItems { get; } + /// /// Performs code completion for the selected item. /// @@ -68,6 +75,11 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion get { return items; } } + /// + public virtual bool ContainsAllAvailableItems { + get { return true; } + } + /// /// Sorts the items by their text. /// diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs index 50a9ea0ab4..47796376be 100644 --- a/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCodeCompletionBinding.cs @@ -64,6 +64,8 @@ namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion { NRefactoryCtrlSpaceCompletionItemProvider provider = new NRefactoryCtrlSpaceCompletionItemProvider(languageProperties); provider.AllowCompleteExistingExpression = true; + // on Ctrl+Space, include items (e.g. types / extension methods) from all namespaces, regardless of imports + provider.ShowItemsFromAllNamespaces = true; provider.ShowCompletion(editor); return true; } diff --git a/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCompletionItemList.cs b/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCompletionItemList.cs new file mode 100644 index 0000000000..13c8820e4a --- /dev/null +++ b/src/Main/Base/Project/Src/Editor/CodeCompletion/NRefactoryCompletionItemList.cs @@ -0,0 +1,29 @@ +// +// +// +// +// $Revision: $ +// +using System; +using ICSharpCode.SharpDevelop.Editor.CodeCompletion; + +namespace ICSharpCode.SharpDevelop.Editor.CodeCompletion +{ + /// + /// created by . + /// + public class NRefactoryCompletionItemList : DefaultCompletionItemList + { + /// + /// sets this to true if this list contains items + /// from all namespaces, regardless of current imports. + /// + public bool ContainsItemsFromAllNamespaces { get; set; } + + /// + public override bool ContainsAllAvailableItems + { + get { return ContainsItemsFromAllNamespaces; } + } + } +} diff --git a/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs b/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs index f873cecee6..ab62863da5 100644 --- a/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs +++ b/src/Main/Base/Project/Src/Gui/AbstractPadContent.cs @@ -42,15 +42,5 @@ namespace ICSharpCode.SharpDevelop.Gui return WorkbenchSingleton.Workbench.GetPad(GetType()); } } - - protected bool IsVisible { - get { - PadDescriptor d = this.PadDescriptor; - if (d != null) - return WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(d); - else - return false; - } - } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs index c0018cf33b..95789a1549 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractOptionPanel.cs @@ -29,12 +29,11 @@ namespace ICSharpCode.SharpDevelop.Gui public virtual object Owner { get; set; } - IList bindings = new List(); + readonly List bindings = new List(); - public IList Bindings { - get { - return bindings; - } + void IOptionBindingContainer.AddBinding(OptionBinding binding) + { + this.bindings.Add(binding); } public virtual object Control { @@ -49,17 +48,12 @@ namespace ICSharpCode.SharpDevelop.Gui public virtual bool SaveOptions() { - foreach (OptionBinding b in Bindings) { + foreach (OptionBinding b in bindings) { if (!b.Save()) return false; } return true; } - - public void AddBinding(OptionBinding binding) - { - this.bindings.Add(binding); - } } } diff --git a/src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs b/src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs index a4433448e7..97f519f018 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbenchLayout.cs @@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop.Gui void UnloadPad(PadDescriptor padDescriptor); /// - /// returns true, if padContent is visible; + /// Returns true, if the pad header is visible (the pad content doesn't need to be visible). /// bool IsVisible(PadDescriptor padDescriptor); diff --git a/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs b/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs index eec15e6226..6a5270212b 100644 --- a/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs +++ b/src/Main/Base/Project/Src/Gui/IWorkbenchWindow.cs @@ -41,7 +41,7 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// Gets/Sets the icon of the view content. /// - System.Windows.Media.Imaging.BitmapSource Icon { + System.Windows.Media.ImageSource Icon { get; set; } diff --git a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs index af127e0990..8f4ac25767 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/CompilerMessageView/FileLineReference.cs @@ -27,19 +27,15 @@ namespace ICSharpCode.SharpDevelop.Gui /// /// The line column. /// - int column ; + int column; /// /// Gets or sets the filename. /// public string FileName { - get { - return fileName; - } - set { - fileName = value; - } + get { return fileName; } + set { fileName = value; } } /// @@ -47,12 +43,8 @@ namespace ICSharpCode.SharpDevelop.Gui /// The value '0' means that no line information is available. /// public int Line { - get { - return line; - } - set { - line = value; - } + get { return line; } + set { line = value; } } /// @@ -60,12 +52,8 @@ namespace ICSharpCode.SharpDevelop.Gui /// The value '0' means that no column information is available. /// public int Column { - get { - return column; - } - set { - column = value; - } + get { return column; } + set { column = value; } } /// /// Creates a new instance of the class. diff --git a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs index b2728c117e..411881346c 100755 --- a/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/DefinitionViewPad.cs @@ -9,8 +9,8 @@ using System; using System.IO; using System.Windows; using System.Windows.Forms; - using ICSharpCode.AvalonEdit; +using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Highlighting; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; @@ -43,7 +43,7 @@ namespace ICSharpCode.SharpDevelop.Gui ctl.IsReadOnly = true; ctl.MouseDoubleClick += OnDoubleClick; ParserService.ParserUpdateStepFinished += OnParserUpdateStep; - //this.IsVisibleChanged += delegate { UpdateTick(null); }; + ctl.IsVisibleChanged += delegate { UpdateTick(null); }; } /// @@ -75,7 +75,7 @@ namespace ICSharpCode.SharpDevelop.Gui void UpdateTick(ParserUpdateStepEventArgs e) { - if (!this.IsVisible) return; + if (!ctl.IsVisible) return; LoggingService.Debug("DefinitionViewPad.Update"); ResolveResult res = ResolveAtCaret(e); @@ -131,9 +131,11 @@ namespace ICSharpCode.SharpDevelop.Gui oldPosition = pos; if (pos.FileName != currentFileName) LoadFile(pos.FileName); - ctl.ScrollToEnd(); // scroll completely down - ctl.TextArea.Caret.Line = pos.Line; - ctl.TextArea.Caret.BringCaretToView(); // scroll up to search position + ctl.TextArea.Caret.Location = new ICSharpCode.AvalonEdit.Document.TextLocation(pos.Line, pos.Column); + Rect r = ctl.TextArea.Caret.CalculateCaretRectangle(); + if (!r.IsEmpty) { + ctl.ScrollToVerticalOffset(r.Top - 4); + } } /// @@ -151,12 +153,11 @@ namespace ICSharpCode.SharpDevelop.Gui // Load the text into the definition view's text editor. if (openTextEditor != null) { -// AvalonEdit.TextEditor aeEditor = openTextEditor.GetService( ctl.Text = openTextEditor.Document.Text; - currentFileName = fileName; } else { ctl.Load(fileName); } + currentFileName = fileName; ctl.SyntaxHighlighting = HighlightingManager.Instance.GetDefinitionByExtension(Path.GetExtension(fileName)); } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs index e32baa5a9f..6eaca8de00 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/TaskList/TaskListPad.cs @@ -229,7 +229,10 @@ namespace ICSharpCode.SharpDevelop.Gui IClass GetCurrentClass(Task item) { - ParseInformation parseInfo = ParserService.GetParseInformation(item.FileName); + // Tasks are created by parsing, so the parse information for item.FileName should already be present. + // If they aren't, that's because the file might have been deleted/renamed in the meantime. + // We use GetExistingParseInformation to avoid trying to parse a file that might have been deleted/renamed. + ParseInformation parseInfo = ParserService.GetExistingParseInformation(item.FileName); if (parseInfo != null) { IClass c = parseInfo.CompilationUnit.GetInnermostClass(item.Line, item.Column); if (c != null) return c; diff --git a/src/Main/Base/Project/Src/Gui/SimpleViewContent.cs b/src/Main/Base/Project/Src/Gui/SimpleViewContent.cs index c6b2e0c8d5..e9112cefbf 100644 --- a/src/Main/Base/Project/Src/Gui/SimpleViewContent.cs +++ b/src/Main/Base/Project/Src/Gui/SimpleViewContent.cs @@ -33,12 +33,12 @@ namespace ICSharpCode.SharpDevelop.Gui /// public new void SetLocalizedTitle(string text) { - base.SetLocalizedTitle("${res:StartPage.StartPageContentName}"); + base.SetLocalizedTitle(text); } public new string TitleName { get { return base.TitleName; } - set { base.TitleName = value; } + set { base.TitleName = value; } // make setter public } } } diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs index 86071c0cc0..30397ad4ca 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonDockLayout.cs @@ -26,7 +26,6 @@ namespace ICSharpCode.SharpDevelop.Gui { WpfWorkbench workbench; DockingManager dockingManager = new DockingManager(); - DocumentPane documentPane = new DocumentPane(); List workbenchWindows = new List(); internal bool Busy; @@ -40,7 +39,6 @@ namespace ICSharpCode.SharpDevelop.Gui public AvalonDockLayout() { - dockingManager.Content = documentPane; dockingManager.PropertyChanged += dockingManager_PropertyChanged; dockingManager.Loaded += dockingManager_Loaded; } @@ -75,7 +73,7 @@ namespace ICSharpCode.SharpDevelop.Gui public event EventHandler ActiveWorkbenchWindowChanged; - public IWorkbenchWindow ActiveWorkbenchWindow { + public IWorkbenchWindow ActiveWorkbenchWindow { get { return dockingManager.ActiveDocument as IWorkbenchWindow; } @@ -180,7 +178,7 @@ namespace ICSharpCode.SharpDevelop.Gui { AvalonPadContent pad; if (pads.TryGetValue(padDescriptor, out pad)) { - dockingManager.Show(pad); + pad.Show(dockingManager); } else { LoggingService.Debug("Add pad " + padDescriptor.Class + " at " + padDescriptor.DefaultPosition); @@ -193,20 +191,27 @@ namespace ICSharpCode.SharpDevelop.Gui public void ActivatePad(PadDescriptor padDescriptor) { - ShowPad(padDescriptor); + AvalonPadContent p; + if (pads.TryGetValue(padDescriptor, out p)) { + if (!p.IsVisible) + p.Show(); + p.Activate(); + } else { + ShowPad(padDescriptor); + } } public void HidePad(PadDescriptor padDescriptor) { AvalonPadContent p; if (pads.TryGetValue(padDescriptor, out p)) - dockingManager.Hide(p); + p.Hide(); } public void UnloadPad(PadDescriptor padDescriptor) { AvalonPadContent p = pads[padDescriptor]; - dockingManager.Hide(p); + p.Hide(); DockablePane pane = p.Parent as DockablePane; if (pane != null) pane.Items.Remove(p); @@ -228,9 +233,9 @@ namespace ICSharpCode.SharpDevelop.Gui workbenchWindows.Add(window); window.ViewContents.Add(content); window.ViewContents.AddRange(content.SecondaryViewContents); - documentPane.Items.Add(window); if (switchToOpenedView) { - dockingManager.Show(window); + window.Show(dockingManager); + window.Activate(); } window.Closed += window_Closed; return window; @@ -278,21 +283,21 @@ namespace ICSharpCode.SharpDevelop.Gui void LoadLayout(string fileName, bool hideAllLostPads) { LoggingService.Info("Loading layout file: " + fileName + ", hideAllLostPads=" + hideAllLostPads); - DockableContent[] oldContents = dockingManager.DockableContents; +// DockableContent[] oldContents = dockingManager.DockableContents; dockingManager.RestoreLayout(fileName); - DockableContent[] newContents = dockingManager.DockableContents; +// DockableContent[] newContents = dockingManager.DockableContents; // Restoring a AvalonDock layout will remove pads that are not // stored in the layout file. // We'll re-add those lost pads. - foreach (DockableContent lostContent in oldContents.Except(newContents)) { - AvalonPadContent padContent = lostContent as AvalonPadContent; - LoggingService.Debug("Re-add lost pad: " + padContent); - if (padContent != null && !hideAllLostPads) { - padContent.ShowInDefaultPosition(); - } else { - dockingManager.Hide(lostContent); - } - } +// foreach (DockableContent lostContent in oldContents.Except(newContents)) { +// AvalonPadContent padContent = lostContent as AvalonPadContent; +// LoggingService.Debug("Re-add lost pad: " + padContent); +// if (padContent != null && !hideAllLostPads) { +// padContent.ShowInDefaultPosition(); +// } else { +// dockingManager.Hide(lostContent); +// } +// } } public void StoreConfiguration() diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonPadContent.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonPadContent.cs index 17fed5450a..25dec9dddb 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonPadContent.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonPadContent.cs @@ -12,7 +12,6 @@ using System.Windows.Input; using System.Windows.Threading; using AvalonDock; -using ICSharpCode.Core; using ICSharpCode.Core.Presentation; namespace ICSharpCode.SharpDevelop.Gui @@ -38,22 +37,20 @@ namespace ICSharpCode.SharpDevelop.Gui this.SetValueToExtension(TitleProperty, new StringParseExtension(descriptor.Title)); placeholder = new TextBlock { Text = this.Title }; this.Content = placeholder; - this.Icon = PresentationResourceService.GetImage(descriptor.Icon); + this.Icon = PresentationResourceService.GetBitmapSource(descriptor.Icon); placeholder.IsVisibleChanged += AvalonPadContent_IsVisibleChanged; } protected override void FocusContent() { + if (!(IsActiveContent && !IsKeyboardFocusWithin)) + return; IInputElement activeChild = CustomFocusManager.GetFocusedChild(this); if (activeChild == null && padInstance != null) { activeChild = padInstance.InitiallyFocusedControl as IInputElement; } - if (activeChild != null) { - LoggingService.Debug("Will move focus to: " + activeChild); - Dispatcher.BeginInvoke(DispatcherPriority.Background, - new Action(delegate { Keyboard.Focus(activeChild); })); - } + AvalonWorkbenchWindow.SetFocus(this, activeChild); } public void ShowInDefaultPosition() @@ -68,9 +65,9 @@ namespace ICSharpCode.SharpDevelop.Gui else style = AnchorStyle.Right; - layout.DockingManager.Show(this, DockableContentState.Docked, style); + this.Show(layout.DockingManager, style); if ((descriptor.DefaultPosition & DefaultPadPositions.Hidden) != 0) - layout.DockingManager.Hide(this); + Hide(); } void AvalonPadContent_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) diff --git a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs index b08a829c16..0d83fe4a68 100644 --- a/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs +++ b/src/Main/Base/Project/Src/Gui/Workbench/Layouts/AvalonWorkbenchWindow.cs @@ -9,12 +9,10 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; -using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Input; -using System.Windows.Media.Imaging; using System.Windows.Threading; using AvalonDock; @@ -40,19 +38,36 @@ namespace ICSharpCode.SharpDevelop.Gui viewContents = new ViewContentCollection(this); ResourceService.LanguageChanged += OnTabPageTextChanged; - OnTitleNameChanged(this, EventArgs.Empty); } protected override void FocusContent() { + if (!(IsActiveContent && !IsKeyboardFocusWithin)) + return; IInputElement activeChild = CustomFocusManager.GetFocusedChild(this); if (activeChild == null && ActiveViewContent != null) { activeChild = ActiveViewContent.InitiallyFocusedControl as IInputElement; } + AvalonWorkbenchWindow.SetFocus(this, activeChild); + } + + internal static void SetFocus(ManagedContent m, IInputElement activeChild) + { if (activeChild != null) { - LoggingService.Debug("Will move focus to: " + activeChild); - Dispatcher.BeginInvoke(DispatcherPriority.Background, - new Action(delegate { Keyboard.Focus(activeChild); })); + LoggingService.Debug(m.Title + " - Will move focus to: " + activeChild); + m.Dispatcher.BeginInvoke( + DispatcherPriority.Background, + new Action( + delegate { + // ensure that condition for FocusContent() is still fulfilled + // (necessary to avoid focus switching loops when changing layouts) + if (!(m.IsActiveContent && !m.IsKeyboardFocusWithin)) { + LoggingService.Debug(m.Title + " - not moving focus"); + return; + } + LoggingService.Debug(m.Title + " - moving focus to: " + activeChild); + Keyboard.Focus(activeChild); + })); } } @@ -232,7 +247,7 @@ namespace ICSharpCode.SharpDevelop.Gui public void SelectWindow() { - this.SetAsActive(); + Activate();//this.SetAsActive(); } public override void OnApplyTemplate() @@ -312,10 +327,10 @@ namespace ICSharpCode.SharpDevelop.Gui if (this.IsDirty) { newTitle += "*"; - } else if (content.IsReadOnly) { - newTitle += "+"; } + IsLocked = content.IsReadOnly; + if (newTitle != Title) { Title = newTitle; OnTitleChanged(EventArgs.Empty); @@ -424,18 +439,6 @@ namespace ICSharpCode.SharpDevelop.Gui public event EventHandler TitleChanged; - BitmapSource icon; - - BitmapSource IWorkbenchWindow.Icon { - get { return icon; } - set { - if (icon != value) { - icon = value; - base.Icon = new Image { Source = value }; - } - } - } - public override string ToString() { return "[AvalonWorkbenchWindow: " + this.Title + "]"; diff --git a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs index 10648204fb..ec521c0b4a 100644 --- a/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs +++ b/src/Main/Base/Project/Src/Gui/WorkbenchSingleton.cs @@ -67,6 +67,7 @@ namespace ICSharpCode.SharpDevelop.Gui StatusBarService.Initialize(); DomHostCallback.Register(); // must be called after StatusBarService.Initialize() ParserService.InitializeParserService(); + TaskService.Initialize(); Bookmarks.BookmarkManager.Initialize(); Project.CustomToolsService.Initialize(); Project.BuildModifiedProjectsOnlyService.Initialize(); diff --git a/src/Main/Base/Project/Src/Internal/Doozers/PadDescriptor.cs b/src/Main/Base/Project/Src/Internal/Doozers/PadDescriptor.cs index 8fdf8aa89d..4aac13f7b4 100644 --- a/src/Main/Base/Project/Src/Internal/Doozers/PadDescriptor.cs +++ b/src/Main/Base/Project/Src/Internal/Doozers/PadDescriptor.cs @@ -180,9 +180,6 @@ namespace ICSharpCode.SharpDevelop { CreatePad(); if (padContent == null) return; - if (!WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(this)) { - WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(this); - } WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this); } diff --git a/src/Main/Base/Project/Src/Project/AbstractProject.cs b/src/Main/Base/Project/Src/Project/AbstractProject.cs index 221e10c311..fccceed433 100644 --- a/src/Main/Base/Project/Src/Project/AbstractProject.cs +++ b/src/Main/Base/Project/Src/Project/AbstractProject.cs @@ -490,7 +490,7 @@ namespace ICSharpCode.SharpDevelop.Project { } - public virtual void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) + public virtual void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) { feedbackSink.ReportError(new BuildError { ErrorText = "Building project " + Name + " is not supported.", IsWarning = true }); // we don't know how to build anything, report that we're done. diff --git a/src/Main/Base/Project/Src/Project/BuildEngine.cs b/src/Main/Base/Project/Src/Project/BuildEngine.cs index 9108095798..3947ea7ca5 100644 --- a/src/Main/Base/Project/Src/Project/BuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/BuildEngine.cs @@ -272,7 +272,7 @@ namespace ICSharpCode.SharpDevelop.Project public void DoStartBuild(object state) { - project.StartBuild(engine.serviceContainer, options, this); + project.StartBuild(options, this); } public void ReportError(BuildError error) @@ -315,7 +315,6 @@ namespace ICSharpCode.SharpDevelop.Project BuildNode rootNode; readonly IBuildable rootProject; readonly BuildResults results = new BuildResults(); - readonly ThreadSafeServiceContainer serviceContainer = new ThreadSafeServiceContainer(); DateTime buildStart; readonly List projectsCurrentlyBuilding = new List(); @@ -538,7 +537,6 @@ namespace ICSharpCode.SharpDevelop.Project /// void ReportDone() { - serviceContainer.Dispose(); if (combinedBuildFeedbackSink != null) { if (combinedBuildFeedbackSink is MessageViewSink) { // Special case GUI-builds so that they have more information available: diff --git a/src/Main/Base/Project/Src/Project/CompilableProject.cs b/src/Main/Base/Project/Src/Project/CompilableProject.cs index ca7b4c4d5c..5d6f5978d9 100644 --- a/src/Main/Base/Project/Src/Project/CompilableProject.cs +++ b/src/Main/Base/Project/Src/Project/CompilableProject.cs @@ -377,6 +377,8 @@ namespace ICSharpCode.SharpDevelop.Project protected override void OnPropertyChanged(ProjectPropertyChangedEventArgs e) { base.OnPropertyChanged(e); + if (e.PropertyName == "TargetFrameworkVersion") + CreateItemsListFromMSBuild(); if (!isLoading) { if (reparseReferencesSensitiveProperties.Contains(e.PropertyName)) { ParserService.Reparse(this, true, false); @@ -466,6 +468,7 @@ namespace ICSharpCode.SharpDevelop.Project #region IUpgradableProject + [Browsable(false)] public virtual bool UpgradeDesired { get { return MinimumSolutionVersion < Solution.SolutionVersionVS2010; diff --git a/src/Main/Base/Project/Src/Project/Converter/IUpgradableProject.cs b/src/Main/Base/Project/Src/Project/Converter/IUpgradableProject.cs index 24ca57b2af..f454b76406 100644 --- a/src/Main/Base/Project/Src/Project/Converter/IUpgradableProject.cs +++ b/src/Main/Base/Project/Src/Project/Converter/IUpgradableProject.cs @@ -85,5 +85,10 @@ namespace ICSharpCode.SharpDevelop.Project.Converter { return MSBuildVersion.GetHashCode(); } + + public override string ToString() + { + return DisplayName; + } } } diff --git a/src/Main/Base/Project/Src/Project/IProject.cs b/src/Main/Base/Project/Src/Project/IProject.cs index 46b901ac77..6075991b94 100644 --- a/src/Main/Base/Project/Src/Project/IProject.cs +++ b/src/Main/Base/Project/Src/Project/IProject.cs @@ -274,7 +274,7 @@ namespace ICSharpCode.SharpDevelop.Project /// Starts building the project using the specified options. /// This member must be implemented thread-safe. /// - void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink); + void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink); /// /// Gets the name of the buildable item. diff --git a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs index 2e19c758b9..8a11603cab 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildBasedProject.cs @@ -77,6 +77,7 @@ namespace ICSharpCode.SharpDevelop.Project /// Gets the MSBuild.Construction project file. /// You must lock on the project's SyncRoot before accessing the MSBuild project file! /// + [Browsable(false)] public ProjectRootElement MSBuildProjectFile { get { if (projectFile == null) @@ -89,6 +90,7 @@ namespace ICSharpCode.SharpDevelop.Project /// Gets the MSBuild.Construction project file. /// You must lock on the project's SyncRoot before accessing the MSBuild project file! /// + [Browsable(false)] public ProjectRootElement MSBuildUserProjectFile { get { if (projectFile == null) @@ -1076,9 +1078,9 @@ namespace ICSharpCode.SharpDevelop.Project return result; } - public override void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) + public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) { - MSBuildEngine.StartBuild(this, buildServices, options, feedbackSink, MSBuildEngine.AdditionalTargetFiles); + MSBuildEngine.StartBuild(this, options, feedbackSink, MSBuildEngine.AdditionalTargetFiles); } public override ProjectBuildOptions CreateProjectBuildOptions(BuildOptions options, bool isRootBuildable) diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine/BuildWorkerManager.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine/BuildWorkerManager.cs index 6313e8c82f..d5a9d93b8c 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine/BuildWorkerManager.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine/BuildWorkerManager.cs @@ -33,6 +33,10 @@ namespace ICSharpCode.SharpDevelop.Project public void RunBuildJob(BuildJob job, IMSBuildChainedLoggerFilter loggerChain, Action reportWhenDone, CancellationToken cancellationToken) { + if (job == null) + throw new ArgumentNullException("job"); + if (loggerChain == null) + throw new ArgumentNullException("loggerChain"); BuildWorker worker = GetFreeWorker(); worker.RunJob(job, loggerChain, reportWhenDone, cancellationToken); } @@ -76,6 +80,7 @@ namespace ICSharpCode.SharpDevelop.Project public void RunJob(BuildJob job, IMSBuildChainedLoggerFilter loggerChain, Action reportWhenDone, CancellationToken cancellationToken) { + Debug.Assert(loggerChain != null); this.loggerChain = loggerChain; this.reportWhenDone = reportWhenDone; try { @@ -119,9 +124,9 @@ namespace ICSharpCode.SharpDevelop.Project void BuildDone(bool success) { lock (this) { + cancellationRegistration.Dispose(); if (reportWhenDone == null) return; - cancellationRegistration.Dispose(); reportWhenDone(success); reportWhenDone = null; } diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs index 5b6f4146ab..1fe3b4b128 100755 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildEngine.cs @@ -93,12 +93,10 @@ namespace ICSharpCode.SharpDevelop.Project MSBuildLoggerFilters = AddInTree.BuildItems(LoggerFiltersPath, null, false); } - public static void StartBuild(IProject project, ThreadSafeServiceContainer serviceContainer, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IEnumerable additionalTargetFiles) + public static void StartBuild(IProject project, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink, IEnumerable additionalTargetFiles) { if (project == null) throw new ArgumentNullException("project"); - if (serviceContainer == null) - throw new ArgumentNullException("serviceContainer"); if (options == null) throw new ArgumentNullException("options"); if (feedbackSink == null) @@ -111,7 +109,6 @@ namespace ICSharpCode.SharpDevelop.Project if (project.MinimumSolutionVersion >= Solution.SolutionVersionVS2010) { engine.additionalTargetFiles.Add(Path.Combine(Path.GetDirectoryName(typeof(MSBuildEngine).Assembly.Location), "SharpDevelop.TargetingPack.targets")); } - engine.serviceContainer = serviceContainer; engine.StartBuild(); } @@ -120,7 +117,6 @@ namespace ICSharpCode.SharpDevelop.Project ProjectBuildOptions options; IBuildFeedbackSink feedbackSink; List additionalTargetFiles; - ThreadSafeServiceContainer serviceContainer; private MSBuildEngine(IProject project, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) { @@ -177,7 +173,14 @@ namespace ICSharpCode.SharpDevelop.Project get { return projectFileName; } } - List interestingTasks = new List(); + /// + /// Gets the minimum solution version (VS version) required to open the project. + /// + public int ProjectMinimumSolutionVersion { + get { return projectMinimumSolutionVersion; } + } + + HashSet interestingTasks = new HashSet(); string temporaryFileName; /// diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildLoggerFilter.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildLoggerFilter.cs index 63487e9701..1c6b5ffda3 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildLoggerFilter.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine/MSBuildLoggerFilter.cs @@ -81,6 +81,8 @@ namespace ICSharpCode.SharpDevelop.Project { if (nextFilter == null) throw new ArgumentNullException("nextFilter"); + // ensure the engine gets notified about start/end of this task + engine.InterestingTasks.Add(taskname); // Create a Filter that tracks whether the task is active. // If active, forward to 'baseFilter', otherwise forward to 'nextFilter'. return new TaskBoundLoggerFilter(this, engine, nextFilter); diff --git a/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs b/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs new file mode 100644 index 0000000000..88876a97fb --- /dev/null +++ b/src/Main/Base/Project/Src/Project/MSBuildEngine/TargetingPackWarningWorkaround.cs @@ -0,0 +1,56 @@ +// +// +// +// +// $Revision$ +// +using System; + +namespace ICSharpCode.SharpDevelop.Project +{ + /// + /// Suppresses the warning MSB3644. + /// + public sealed class TargetingPackWarningWorkaround : IMSBuildLoggerFilter + { + /* + * Warning MSB3644: The reference assemblies for framework + * ".NETFramework,Version=v4.0,Profile=Client" were not found. To resolve this, + * install the SDK or Targeting Pack for this framework version or retarget + * your application to a version of the framework for which you have the SDK + * or Targeting Pack installed. Note that assemblies will be resolved from + * the Global Assembly Cache (GAC) and will be used in place of reference assemblies. + * Therefore your assembly may not be correctly targeted for the framework you intend. + */ + + public IMSBuildChainedLoggerFilter CreateFilter(MSBuildEngine engine, IMSBuildChainedLoggerFilter nextFilter) + { + if (engine.ProjectMinimumSolutionVersion >= Solution.SolutionVersionVS2010) { + return new TargetingPackWarningWorkaroundChainEntry(nextFilter); + } else { + return nextFilter; + } + } + + sealed class TargetingPackWarningWorkaroundChainEntry : IMSBuildChainedLoggerFilter + { + readonly IMSBuildChainedLoggerFilter nextFilter; + + public TargetingPackWarningWorkaroundChainEntry(IMSBuildChainedLoggerFilter nextFilter) + { + this.nextFilter = nextFilter; + } + + public void HandleError(BuildError error) + { + if (error.ErrorCode != "MSB3644") + nextFilter.HandleError(error); + } + + public void HandleBuildEvent(Microsoft.Build.Framework.BuildEventArgs e) + { + nextFilter.HandleBuildEvent(e); + } + } + } +} diff --git a/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs b/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs index 233a300052..ccfe8feeab 100644 --- a/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs +++ b/src/Main/Base/Project/Src/Project/MSBuildFileProject.cs @@ -22,9 +22,9 @@ namespace ICSharpCode.SharpDevelop.Project TypeGuid = "{00000000-0000-0000-0000-000000000000}"; } - public override void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) + public override void StartBuild(ProjectBuildOptions options, IBuildFeedbackSink feedbackSink) { - MSBuildEngine.StartBuild(this, buildServices, options, feedbackSink, MSBuildEngine.AdditionalTargetFiles); + MSBuildEngine.StartBuild(this, options, feedbackSink, MSBuildEngine.AdditionalTargetFiles); } } } diff --git a/src/Main/Base/Project/Src/Project/Solution/Solution.cs b/src/Main/Base/Project/Src/Project/Solution/Solution.cs index dae8dce496..1972ffc99f 100644 --- a/src/Main/Base/Project/Src/Project/Solution/Solution.cs +++ b/src/Main/Base/Project/Src/Project/Solution/Solution.cs @@ -1202,7 +1202,7 @@ namespace ICSharpCode.SharpDevelop.Project return result; } - void IBuildable.StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) + void IBuildable.StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { // building a solution finishes immediately: we only care for the dependencies feedbackSink.Done(true); diff --git a/src/Main/Base/Project/Src/Services/File/RecentOpen.cs b/src/Main/Base/Project/Src/Services/File/RecentOpen.cs index 2d420a1d15..75cc22da08 100644 --- a/src/Main/Base/Project/Src/Services/File/RecentOpen.cs +++ b/src/Main/Base/Project/Src/Services/File/RecentOpen.cs @@ -51,19 +51,21 @@ namespace ICSharpCode.SharpDevelop { // don't check whether files exist because that might be slow (e.g. if file is on network // drive that's unavailable) - if (p.Contains("Files")) { - lastfile.AddRange(p["Files"].Split(',')); + + // if one of these entries is a string, then it's from a previous SharpDevelop version - don't try loading it + if (p.Contains("Files") && !(p.Get("Files") is string)) { + lastfile.AddRange(p.Get("Files", new string[0])); } - if (p.Contains("Projects")) { - lastproject.AddRange(p["Projects"].Split(',')); + if (p.Contains("Projects") && !(p.Get("Files") is string)) { + lastproject.AddRange(p.Get("Projects", new string[0])); } } public void AddLastFile(string name) { for (int i = 0; i < lastfile.Count; ++i) { - if (lastfile[i].ToString().Equals(name, StringComparison.OrdinalIgnoreCase)) { + if (lastfile[i].Equals(name, StringComparison.OrdinalIgnoreCase)) { lastfile.RemoveAt(i); } } @@ -72,11 +74,7 @@ namespace ICSharpCode.SharpDevelop lastfile.RemoveAt(lastfile.Count - 1); } - if (lastfile.Count > 0) { - lastfile.Insert(0, name); - } else { - lastfile.Add(name); - } + lastfile.Insert(0, name); } public void ClearRecentFiles() @@ -101,11 +99,7 @@ namespace ICSharpCode.SharpDevelop lastproject.RemoveAt(lastproject.Count - 1); } - if (lastproject.Count > 0) { - lastproject.Insert(0, name); - } else { - lastproject.Add(name); - } + lastproject.Insert(0, name); JumpList.AddToRecentCategory(name); } @@ -117,8 +111,8 @@ namespace ICSharpCode.SharpDevelop public Properties ToProperties() { Properties p = new Properties(); - p["Files"] = String.Join(",", lastfile.ToArray()); - p["Projects"] = String.Join(",", lastproject.ToArray()); + p.Set("Files", lastfile.ToArray()); + p.Set("Projects", lastproject.ToArray()); return p; } diff --git a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs index 025eceb3b4..fb2f4c277b 100644 --- a/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs +++ b/src/Main/Base/Project/Src/Services/ParserService/ParserService.cs @@ -257,7 +257,7 @@ namespace ICSharpCode.SharpDevelop } /// - /// Resolves expression at given position. + /// Resolves expression at given position. /// That is, finds ExpressionResult at that position and /// calls the overload Resolve(ExpressionResult,...). /// @@ -450,6 +450,11 @@ namespace ICSharpCode.SharpDevelop // ensure we never go backwards in time (we need to repeat this check after we've reacquired the lock) if (fileContentVersion != null && this.bufferVersion != null && this.bufferVersion.BelongsToSameDocumentAs(fileContentVersion)) { if (this.bufferVersion.CompareAge(fileContentVersion) >= 0) { + if (parentProjectContent != null && parentProjectContent != parseInfo.CompilationUnit.ProjectContent) { + ICompilationUnit oldUnit = oldUnits.FirstOrDefault(o => o.ProjectContent == parentProjectContent); + if (oldUnit != null) + return new ParseInformation(oldUnit); + } return this.parseInfo; } } @@ -476,7 +481,6 @@ namespace ICSharpCode.SharpDevelop this.bufferVersion = fileContentVersion; this.oldUnits = newUnits; this.parseInfo = newParseInfo; - TaskService.UpdateCommentTags(fileName, resultUnit.TagComments); return newParseInfo; } } @@ -788,6 +792,7 @@ namespace ICSharpCode.SharpDevelop // To ensure events are raised in the same order, we always invoke on the main thread. WorkbenchSingleton.SafeThreadAsyncCall( delegate { + LoggingService.Debug("ParseInformationUpdated " + e.FileName + " new!=null:" + (e.NewCompilationUnit!=null)); ParseInformationUpdated(null, e); }); } diff --git a/src/Main/Base/Project/Src/Services/ProjectService/CompileModifiedProjectsOnly.cs b/src/Main/Base/Project/Src/Services/ProjectService/CompileModifiedProjectsOnly.cs index be51dcc4aa..dd0ead90ef 100644 --- a/src/Main/Base/Project/Src/Services/ProjectService/CompileModifiedProjectsOnly.cs +++ b/src/Main/Base/Project/Src/Services/ProjectService/CompileModifiedProjectsOnly.cs @@ -151,7 +151,7 @@ namespace ICSharpCode.SharpDevelop.Project return new IBuildable[0]; } - public void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) + public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { } } @@ -245,11 +245,11 @@ namespace ICSharpCode.SharpDevelop.Project return lastCompilationPass.Index > comparisonPass.Index; } - public void StartBuild(ThreadSafeServiceContainer buildServices, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) + public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { IProject p = wrapped as IProject; if (p == null) { - wrapped.StartBuild(buildServices, buildOptions, feedbackSink); + wrapped.StartBuild(buildOptions, feedbackSink); } else { lock (unmodifiedProjects) { if (!unmodifiedProjects.TryGetValue(p, out lastCompilationPass)) { @@ -272,7 +272,7 @@ namespace ICSharpCode.SharpDevelop.Project feedbackSink.Done(true); } else { lastCompilationPass = factory.CurrentPass; - wrapped.StartBuild(buildServices, buildOptions, new BuildFeedbackSink(p, feedbackSink, factory.CurrentPass)); + wrapped.StartBuild(buildOptions, new BuildFeedbackSink(p, feedbackSink, factory.CurrentPass)); } } } diff --git a/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs b/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs index 2d3f530eb5..701385bb3a 100644 --- a/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs +++ b/src/Main/Base/Project/Src/Services/Tasks/TaskService.cs @@ -79,9 +79,26 @@ namespace ICSharpCode.SharpDevelop } } - static TaskService() + internal static void Initialize() { - ProjectService.SolutionClosed += new EventHandler(ProjectServiceSolutionClosed); + // avoid trouble with double initialization + ParserService.ParseInformationUpdated -= ParserService_ParseInformationUpdated; + ParserService.ParseInformationUpdated += ParserService_ParseInformationUpdated; + ProjectService.SolutionClosed -= ProjectServiceSolutionClosed; + ProjectService.SolutionClosed += ProjectServiceSolutionClosed; + } + + static void ParserService_ParseInformationUpdated(object sender, ParseInformationEventArgs e) + { + if (e.NewParseInformation == ParserService.GetExistingParseInformation(e.FileName)) { + // Call UpdateCommentTags only for the main parse information (if a file is in multiple projects), + // and only if the results haven't already been replaced with a more recent ParseInformation. + if (e.NewCompilationUnit != null) { + UpdateCommentTags(e.FileName, e.NewCompilationUnit.TagComments); + } else { + UpdateCommentTags(e.FileName, new List()); + } + } } static void ProjectServiceSolutionClosed(object sender, EventArgs e) @@ -132,15 +149,7 @@ namespace ICSharpCode.SharpDevelop } } - public static void UpdateCommentTags(string fileName, IList tagComments) - { - if (fileName == null || tagComments == null) { - return; - } - WorkbenchSingleton.SafeThreadAsyncCall(UpdateCommentTagsInvoked, FileName.Create(fileName), tagComments); - } - - static void UpdateCommentTagsInvoked(FileName fileName, IList tagComments) + static void UpdateCommentTags(FileName fileName, IList tagComments) { List newTasks = new List(); foreach (TagComment tag in tagComments) { diff --git a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs index b937a32e78..876ac81930 100644 --- a/src/Main/Base/Project/Src/Util/ExtensionMethods.cs +++ b/src/Main/Base/Project/Src/Util/ExtensionMethods.cs @@ -17,7 +17,6 @@ using System.Windows.Controls; using System.Windows.Media; using System.Windows.Documents; using System.Windows.Forms; - using ICSharpCode.Core.Presentation; using ICSharpCode.SharpDevelop.Gui; using WinForms = System.Windows.Forms; @@ -319,6 +318,36 @@ namespace ICSharpCode.SharpDevelop } #endregion + /// + /// Removes from the start of this string. + /// Throws ArgumentException if this string does not start with . + /// + public static string RemoveStart(this string s, string stringToRemove) + { + if (s == null) + return null; + if (string.IsNullOrEmpty(stringToRemove)) + return s; + if (!s.StartsWith(stringToRemove)) + throw new ArgumentException(string.Format("{0} does not start with {1}", s, stringToRemove)); + return s.Substring(stringToRemove.Length); + } + + /// + /// Removes from the end of this string. + /// Throws ArgumentException if this string does not end with . + /// + public static string RemoveEnd(this string s, string stringToRemove) + { + if (s == null) + return null; + if (string.IsNullOrEmpty(stringToRemove)) + return s; + if (!s.EndsWith(stringToRemove)) + throw new ArgumentException(string.Format("{0} does not end with {1}", s, stringToRemove)); + return s.Substring(0, s.Length - stringToRemove.Length); + } + public static string Replace(this string original, string pattern, string replacement, StringComparison comparisonType) { if (original == null) @@ -406,12 +435,13 @@ namespace ICSharpCode.SharpDevelop } /// - /// Returns the index of the first element for which constraint returns true. - /// If none of the items in the list fits the constraint -1 is returned. + /// Returns the index of the first element for which returns true. + /// If none of the items in the list fits the , -1 is returned. /// - public static int FindIndex(this IList list, Func constraint) { + public static int FindIndex(this IList list, Func predicate) + { for (int i = 0; i < list.Count; i++) { - if (constraint(list[i])) + if (predicate(list[i])) return i; } diff --git a/src/Main/Base/Project/Src/Util/NativeMethods.cs b/src/Main/Base/Project/Src/Util/NativeMethods.cs index d2fbfd9381..fc87e98c03 100644 --- a/src/Main/Base/Project/Src/Util/NativeMethods.cs +++ b/src/Main/Base/Project/Src/Util/NativeMethods.cs @@ -94,7 +94,7 @@ namespace ICSharpCode.SharpDevelop info.pFrom = fileName + "\0"; // pFrom is double-null-terminated int result = SHFileOperation(ref info); if (result != 0) - throw new IOException("Could not delete file " + fileName + ". Error " + result); + throw new IOException("Could not delete file " + fileName + ". Error " + result, result); } #endregion diff --git a/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs b/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs index c718f2c861..1ddba20b3d 100644 --- a/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs +++ b/src/Main/Base/Project/Src/Util/SDWindowsFormsHost.cs @@ -43,22 +43,31 @@ namespace ICSharpCode.SharpDevelop.Gui void AddBinding(ICommand command, Action execute, Predicate canExecute) where T : class { - ExecutedRoutedEventHandler onExected = (sender, e) => { - var cbh = GetInterface(); - if (cbh != null) { - e.Handled = true; - if (canExecute(cbh)) - execute(cbh); + ExecutedRoutedEventHandler onExecuted = (sender, e) => { + if (e.Command == command) { + var cbh = GetInterface(); + if (cbh != null) { + e.Handled = true; + if (canExecute(cbh)) + execute(cbh); + } } }; CanExecuteRoutedEventHandler onCanExecute = (sender, e) => { - var cbh = GetInterface(); - if (cbh != null) { - e.Handled = true; - e.CanExecute = canExecute(cbh); + if (e.Command == command) { + var cbh = GetInterface(); + if (cbh != null) { + e.Handled = true; + e.CanExecute = canExecute(cbh); + } } }; - this.CommandBindings.Add(new CommandBinding(command, onExected, onCanExecute)); + //this.CommandBindings.Add(new CommandBinding(command, onExecuted, onCanExecute)); + // Don't use this.CommandBindings because CommandBindings with built-in shortcuts would handle the key press + // before WinForms gets to see it. Using the events ensures that the command gets executed only when the user + // clicks on the menu/toolbar item. (this fixes SD2-1671) + CommandManager.AddCanExecuteHandler(this, onCanExecute); + CommandManager.AddExecutedHandler(this, onExecuted); } #endregion diff --git a/src/Main/Base/Project/Src/Util/WpfSynchronizeInvoke.cs b/src/Main/Base/Project/Src/Util/WpfSynchronizeInvoke.cs index b6860591da..970324f28f 100644 --- a/src/Main/Base/Project/Src/Util/WpfSynchronizeInvoke.cs +++ b/src/Main/Base/Project/Src/Util/WpfSynchronizeInvoke.cs @@ -7,6 +7,7 @@ using System; using System.ComponentModel; +using System.Reflection; using System.Threading; using System.Windows.Threading; @@ -103,12 +104,21 @@ namespace ICSharpCode.SharpDevelop public object Invoke(Delegate method, object[] args) { - if (args.Length == 0) - return dispatcher.Invoke(DispatcherPriority.Normal, method); - else if (args.Length == 1) - return dispatcher.Invoke(DispatcherPriority.Normal, method, args[0]); - else - return dispatcher.Invoke(DispatcherPriority.Normal, method, args[0], args.Splice(1)); + object result = null; + Exception exception = null; + dispatcher.Invoke( + DispatcherPriority.Normal, + (Action)delegate { + try { + result = method.DynamicInvoke(args); + } catch (TargetInvocationException ex) { + exception = ex.InnerException; + } + }); + // if an exception occurred, re-throw it on the calling thread + if (exception != null) + throw new TargetInvocationException(exception); + return result; } } } diff --git a/src/Main/Base/Test/StringTagProvider/MockProjectForTagProvider.cs b/src/Main/Base/Test/StringTagProvider/MockProjectForTagProvider.cs index c827fb1d04..e32ba4fc2e 100644 --- a/src/Main/Base/Test/StringTagProvider/MockProjectForTagProvider.cs +++ b/src/Main/Base/Test/StringTagProvider/MockProjectForTagProvider.cs @@ -255,7 +255,7 @@ namespace ICSharpCode.SharpDevelop.Tests.StringTagProvider throw new NotImplementedException(); } - public void StartBuild(ThreadSafeServiceContainer serviceContainer, ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) + public void StartBuild(ProjectBuildOptions buildOptions, IBuildFeedbackSink feedbackSink) { throw new NotImplementedException(); } diff --git a/src/Main/GlobalAssemblyInfo.template b/src/Main/GlobalAssemblyInfo.template index d75b703800..1f24ad0da8 100644 --- a/src/Main/GlobalAssemblyInfo.template +++ b/src/Main/GlobalAssemblyInfo.template @@ -33,4 +33,6 @@ internal static class RevisionClass public const string MainVersion = Major + "." + Minor; public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision; + + public const string BranchName = "vbnet"; } diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs index d3714bf730..38b34b7f3a 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/CtrlSpaceResolveHelper.cs @@ -235,7 +235,7 @@ namespace ICSharpCode.SharpDevelop.Dom return null; } - public static IList FindAllExtensions(LanguageProperties language, IClass callingClass) + public static IList FindAllExtensions(LanguageProperties language, IClass callingClass, bool searchInAllNamespaces = false) { if (language == null) throw new ArgumentNullException("language"); @@ -251,9 +251,12 @@ namespace ICSharpCode.SharpDevelop.Dom IMethod dummyMethod = new DefaultMethod("dummy", callingClass.ProjectContent.SystemTypes.Void, ModifierEnum.Static, DomRegion.Empty, DomRegion.Empty, callingClass); CtrlSpaceResolveHelper.AddContentsFromCalling(list, callingClass, dummyMethod); - CtrlSpaceResolveHelper.AddImportedNamespaceContents(list, callingClass.CompilationUnit, callingClass); - // search extension methods in all referenced projects, no matter the using section - //CtrlSpaceResolveHelper.AddReferencedProjectsContents(list, callingClass.CompilationUnit, callingClass); + if (searchInAllNamespaces) { + // search extension methods in all referenced projects, no matter the using section + CtrlSpaceResolveHelper.AddReferencedProjectsContents(list, callingClass.CompilationUnit, callingClass); + } else { + CtrlSpaceResolveHelper.AddImportedNamespaceContents(list, callingClass.CompilationUnit, callingClass); + } bool searchExtensionsInClasses = language.SearchExtensionsInClasses; foreach (object o in list) { diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs index d1ffb1f2b6..36d0ef4881 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/NRefactoryResolver/NRefactoryResolver.cs @@ -1010,13 +1010,13 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver ReadOnlyCollection cachedExtensionMethods; IClass cachedExtensionMethods_LastClass; // invalidate cache when callingClass != LastClass - public ReadOnlyCollection SearchAllExtensionMethods() + public ReadOnlyCollection SearchAllExtensionMethods(bool searchInAllNamespaces = false) { if (callingClass == null) return EmptyList.Instance; if (callingClass != cachedExtensionMethods_LastClass) { cachedExtensionMethods_LastClass = callingClass; - cachedExtensionMethods = new ReadOnlyCollection(CtrlSpaceResolveHelper.FindAllExtensions(languageProperties, callingClass)); + cachedExtensionMethods = new ReadOnlyCollection(CtrlSpaceResolveHelper.FindAllExtensions(languageProperties, callingClass, searchInAllNamespaces)); } return cachedExtensionMethods; } @@ -1131,7 +1131,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } } - public List CtrlSpace(int caretLine, int caretColumn, ParseInformation parseInfo, string fileContent, ExpressionContext context) + /// + /// Returns code completion entries for given context. + /// + /// + /// + /// + /// + /// + /// If true, returns entries from all namespaces, regardless of current imports. + /// + public List CtrlSpace(int caretLine, int caretColumn, ParseInformation parseInfo, string fileContent, ExpressionContext context, bool showEntriesFromAllNamespaces = false) { if (!Initialize(parseInfo, caretLine, caretColumn)) return null; @@ -1145,7 +1155,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver AddVBNetKeywords(result, NR.Parser.VB.Tokens.GlobalLevel); } else { AddVBNetPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } result.Add(new KeywordEntry("Global")); @@ -1155,16 +1165,16 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver if (context == ExpressionContext.TypeDeclaration) { AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.TypeLevel); AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else if (context == ExpressionContext.InterfaceDeclaration) { AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InterfaceLevel); AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else if (context == ExpressionContext.MethodBody) { result.Add(new KeywordEntry("var")); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.StatementStart); AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else if (context == ExpressionContext.Global) { AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.GlobalLevel); } else if (context == ExpressionContext.InterfacePropertyDeclaration) { @@ -1181,11 +1191,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver result.Add(new KeywordEntry("struct")); result.Add(new KeywordEntry("class")); AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else if (context == ExpressionContext.InheritableType) { result.Add(new KeywordEntry("where")); // the inheritance list can be followed by constraints AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else if (context == ExpressionContext.PropertyDeclaration) { AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.InPropertyDeclaration); } else if (context == ExpressionContext.EventDeclaration) { @@ -1202,17 +1212,17 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } } AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else if (context == ExpressionContext.ObjectInitializer) { bool isCollectionInitializer; result.AddRange(ObjectInitializerCtrlSpace(fileContent, out isCollectionInitializer)); if (isCollectionInitializer) { AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.ExpressionStart); AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } } else if (context == ExpressionContext.Attribute) { - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); result.Add(new KeywordEntry("assembly")); result.Add(new KeywordEntry("module")); result.Add(new KeywordEntry("field")); @@ -1226,11 +1236,11 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.ExpressionStart); AddCSharpKeywords(result, NR.Parser.CSharp.Tokens.ExpressionContent); AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } else { // e.g. some ExpressionContext.TypeDerivingFrom() AddCSharpPrimitiveTypes(result); - CtrlSpaceInternal(result, fileContent); + CtrlSpaceInternal(result, fileContent, showEntriesFromAllNamespaces); } } return result; @@ -1255,7 +1265,7 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver } } - void CtrlSpaceInternal(List result, string fileContent) + void CtrlSpaceInternal(List result, string fileContent, bool showEntriesFromAllNamespaces) { lookupTableVisitor = new LookupTableVisitor(language); @@ -1289,11 +1299,13 @@ namespace ICSharpCode.SharpDevelop.Dom.NRefactoryResolver result.Add(new DefaultField.ParameterField(callingMember.ReturnType, "value", callingMember.Region, callingClass)); } - // CC contains contents of all imported namespaces - //CtrlSpaceResolveHelper.AddImportedNamespaceContents(result, cu, callingClass); // FindReferences to AddImportedNamespaceContents results in OutOfMemory - + if (showEntriesFromAllNamespaces) { // CC contains contents of all referenced assemblies CtrlSpaceResolveHelper.AddReferencedProjectsContents(result, cu, callingClass); + } else { + // CC contains contents of all imported namespaces + CtrlSpaceResolveHelper.AddImportedNamespaceContents(result, cu, callingClass); + } } sealed class CompareLambdaByLocation : IEqualityComparer diff --git a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ResolveResult.cs b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ResolveResult.cs index d5e5b8fa1d..2289780acf 100644 --- a/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ResolveResult.cs +++ b/src/Main/ICSharpCode.SharpDevelop.Dom/Project/Src/ResolveResult.cs @@ -78,6 +78,24 @@ namespace ICSharpCode.SharpDevelop.Dom return this.Clone(); } + bool showAllNamespacesContentsInCC = false; + /// + /// Gets code completion data for this ResolveResult. + /// + /// + /// If true, items (e.g. extension methods) from all namespaces are returned, regardless current imports. Default is false. + /// + public List GetCompletionData(IProjectContent projectContent, bool showItemsFromAllNamespaces) + { + // Little hack - store value in a property to pass it to GetCompletionData(LanguageProperties language, bool showStatic) + // Otherwise we would have to add it as a parameter to GetCompletionData(IProjectContent projectContent), + // which would change signature in classes overriding this method as well. + this.showAllNamespacesContentsInCC = showItemsFromAllNamespaces; + var result = GetCompletionData(projectContent); + this.showAllNamespacesContentsInCC = false; + return result; + } + public virtual List GetCompletionData(IProjectContent projectContent) { return GetCompletionData(projectContent.Language, false); @@ -94,7 +112,7 @@ namespace ICSharpCode.SharpDevelop.Dom } if (!showStatic && callingClass != null) { - AddExtensions(language, res.Add, callingClass, resolvedType); + AddExtensions(language, res.Add, callingClass, resolvedType, this.showAllNamespacesContentsInCC); } return res; @@ -103,7 +121,7 @@ namespace ICSharpCode.SharpDevelop.Dom /// /// Adds extension methods to . /// - public static void AddExtensions(LanguageProperties language, Action methodFound, IClass callingClass, IReturnType resolvedType) + public static void AddExtensions(LanguageProperties language, Action methodFound, IClass callingClass, IReturnType resolvedType, bool searchInAllNamespaces = false) { if (language == null) throw new ArgumentNullException("language"); @@ -117,7 +135,7 @@ namespace ICSharpCode.SharpDevelop.Dom // convert resolvedType into direct type to speed up the IsApplicable lookups resolvedType = resolvedType.GetDirectReturnType(); - foreach (IMethodOrProperty mp in CtrlSpaceResolveHelper.FindAllExtensions(language, callingClass)) { + foreach (IMethodOrProperty mp in CtrlSpaceResolveHelper.FindAllExtensions(language, callingClass, searchInAllNamespaces)) { TryAddExtension(language, methodFound, mp, resolvedType); } } diff --git a/src/Main/StartUp/Project/Dialogs/SplashScreen.cs b/src/Main/StartUp/Project/Dialogs/SplashScreen.cs index f947f26572..5963bddb1b 100644 --- a/src/Main/StartUp/Project/Dialogs/SplashScreen.cs +++ b/src/Main/StartUp/Project/Dialogs/SplashScreen.cs @@ -14,8 +14,6 @@ namespace ICSharpCode.SharpDevelop { public class SplashScreenForm : Form { - public const string VersionText = "Mirador (4.0) build " + RevisionClass.Revision; - static SplashScreenForm splashScreen; static List requestedFileList = new List(); static List parameterList = new List(); @@ -32,20 +30,23 @@ namespace ICSharpCode.SharpDevelop public SplashScreenForm() { + const string versionText = "SharpDevelop" + + (RevisionClass.BranchName != null ? "-" + RevisionClass.BranchName : "") + + " " + RevisionClass.FullVersion + #if DEBUG + + " (debug)" + #endif + ; + FormBorderStyle = FormBorderStyle.None; StartPosition = FormStartPosition.CenterScreen; ShowInTaskbar = false; - #if DEBUG - string versionText = VersionText + " (debug)"; - #else - string versionText = VersionText; - #endif // Stream must be kept open for the lifetime of the bitmap bitmap = new Bitmap(typeof(SplashScreenForm).Assembly.GetManifestResourceStream("Resources.SplashScreen.jpg")); this.ClientSize = bitmap.Size; using (Font font = new Font("Sans Serif", 4)) { using (Graphics g = Graphics.FromImage(bitmap)) { - g.DrawString(versionText, font, Brushes.Black, 100, 142); + g.DrawString(versionText, font, Brushes.Black, 166 - 3 * versionText.Length, 142); } } BackgroundImage = bitmap; diff --git a/src/Setup/Files.wxs b/src/Setup/Files.wxs index cb00ad58af..3567dd1352 100644 --- a/src/Setup/Files.wxs +++ b/src/Setup/Files.wxs @@ -10,72 +10,72 @@ + NGens SharpDevelop.exe. Needs the NetFx extension (WixNetFxExtension.dll), + library (netfx.wixlib) and custom actions (netfxca.dll). + + Priority=0 means the image generation occurs during + setup. Other values defer the generation. + + Default Platform value is 32bit which tries to generate images + for 32 bitversions of the .NET framework on the + target machine. This will fail on a machine with + 64 bit version of .NET. Cannot use Platform=all + since this runs NGen for both 32 and 64 bit versions + regardless of whether they exist on the target + machine. + --> + Get several ICE33 warnings using the ProgId element + but these apparently can safely be ignored + according to a post on the wix-users list by + Rob Mencshing. Also using the ProgId element + does not create the ProgId table. The current installer + no longer uses the ProgId but instead uses Registry + keys instead. It still creates the same entries in the + msi. + + http://sourceforge.net/mailarchive/message.php?msg_id=9075241 + + Note that the Target of the form [#FileId] expands out to the + full path of the file. A target of the form [!FileId] + expands to the short name of the file (i.e. it includes ~ + characters). We need the full path otherwise the exe name + will be something like SharpDev~1.exe and the + SharpDevelop.exe.manifest file will not be found when + running the application so it does not use XP visual styles. + Unfortunately using [#FileId] generates lots of ICE69 + warnings for the icon and the SharpDevelop.exe target + if they are in a different component. + Not sure why [!FileId] does not produce an error since + the problem seems to be similar, basically the registry + key generated by the ProgId element belongs to one + component whilst we are referencing another component + containing the SharpDevelop.exe and another + containing the icon. + + http://msdn.microsoft.com/library/en-us/msi/setup/ice69.asp + + The ICE69 errors can be ignored for now since the component + being referenced by the file associations will always be installed + even though it is in a different feature. If the FileTypeRegister + addin is an optional install then the ICE69 errors would need to + be resolved. + + We are not using the ProgId element which sets up the + file association registry keys for us, but are specifying them + directly as registry keys. This allows us to use one of the keys + as a key path instead of having to use the parent component's + directory as the key path. The key path is what is used + by the installer to detect whether the component is installed. + Using the component's parent directory (i.e. the Bin folder) + is not feasible since the file associations may not be installed + if the user does not install them in the feature tree. + --> @@ -153,13 +153,14 @@ - + + @@ -211,8 +212,8 @@ - - + + @@ -652,10 +653,11 @@ - + + @@ -946,13 +948,13 @@ + + + + + + + --> @@ -1036,6 +1038,14 @@ + + + + + + + + @@ -1181,35 +1191,35 @@ - + + + --> + @@ -1332,14 +1342,10 @@ - + - - - - - - + + @@ -1461,80 +1467,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + --> + The choice here is to either useW the IniFile element to + generate the two website shortcuts or create a + SharpDevelop.url file on disk and use a File element and + link to the file instead. We will use a file otherwise an + upgrade will not remove the existing website shortcut. + --> + ICE18 - Force the empty folder to be created. Even though it + has sub folders the validator flags this as an error. + + http://msdn.microsoft.com/library/en-us/msi/setup/ice18.asp + --> + App Path registry setting lives in HKLM so only add it if the + user has admin rights. + --> Privileged + Dummy components that are empty. These are used so + the feature tree does not show the Network installation + as an option. + --> + Fix ICE18 error. The validator thinks that the install folder + could be empty so we have to use CreateFolder in this component. + + http://msdn.microsoft.com/library/en-us/msi/setup/ice18.asp + --> + Fix ICE18 error. The validator thinks that the install folder + could be empty so we have to use CreateFolder in this component. + + http://msdn.microsoft.com/library/en-us/msi/setup/ice18.asp + --> @@ -1544,9 +1550,9 @@ + Fix ICE 38 by adding a dummy registry key that is the key for this shortcut. + http://msdn.microsoft.com/library/en-us/msi/setup/ice38.asp + --> @@ -1555,9 +1561,9 @@ + Fix ICE 38 by adding a dummy registry key that is the key for this shortcut. + http://msdn.microsoft.com/library/en-us/msi/setup/ice38.asp + --> diff --git a/src/Setup/Setup.wxs b/src/Setup/Setup.wxs index e1091fbe15..c572ef2709 100644 --- a/src/Setup/Setup.wxs +++ b/src/Setup/Setup.wxs @@ -47,7 +47,7 @@ "Installed OR" this would not be allowed. --> @@ -60,6 +60,12 @@ Installed OR NETFRAMEWORK40FULL + + + + Installed OR NETFRAMEWORK35_SP_LEVEL = "#1" + +