Browse Source

add WPF designer back

newNRvisualizers
Siegfried Pammer 13 years ago
parent
commit
7eb5641bcf
  1. 62
      SharpDevelop.Tests.sln
  2. 51
      SharpDevelop.sln
  3. 1
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  4. 2
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj
  5. 11
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs
  6. 93
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs
  7. 135
      src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/MoveTypeToFileContextAction.cs
  8. 6
      src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlResolver.cs
  9. 70
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs
  10. 42
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/CSharpEventHandlerService.cs
  11. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/FileUriContext.cs
  12. 32
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs
  13. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs
  14. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/PropertyDescriptionService.cs
  15. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfDisplayBinding.cs
  16. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  17. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  18. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin
  19. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  20. 18
      src/Main/Base/Project/Designer/IDesignerTypeResolutionService.cs
  21. 576
      src/Main/Base/Project/Designer/TypeResolutionService.cs
  22. 14
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  23. 0
      src/Main/Base/Project/Refactoring/ContextAction.cs
  24. 0
      src/Main/Base/Project/Refactoring/EditorRefactoringContext.cs
  25. 18
      src/Main/Base/Project/Refactoring/ICodeGenerator.cs
  26. 0
      src/Main/Base/Project/Refactoring/IContextAction.cs
  27. 0
      src/Main/Base/Project/Refactoring/IContextActionProvider.cs
  28. 4
      src/Main/Base/Project/Src/Gui/Components/FontSelector.xaml.cs
  29. 8
      src/Main/Base/Project/Src/Project/AbstractProject.cs
  30. 7
      src/Main/Base/Project/Src/Project/IProject.cs
  31. 21
      src/Main/Base/Project/Util/SharpDevelopExtensions.cs

62
SharpDevelop.Tests.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.3
# SharpDevelop 5.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -151,6 +151,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigne @@ -151,6 +151,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigne
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}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}"
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{AF5E0DC1-1FA0-4346-A436-0C817C68F7C1}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -625,6 +639,46 @@ Global @@ -625,6 +639,46 @@ Global
DC88D67C-E6B5-4994-9FA9-D4AB0E162FB3.Release|Any CPU.ActiveCfg = Release|Any CPU
DC88D67C-E6B5-4994-9FA9-D4AB0E162FB3.Release|x86.Build.0 = Release|Any CPU
DC88D67C-E6B5-4994-9FA9-D4AB0E162FB3.Release|x86.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|x86.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|x86.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|x86.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|x86.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|x86.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|x86.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|x86.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|x86.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|x86.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|x86.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|x86.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|x86.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|x86.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|x86.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|x86.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|x86.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|x86.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|x86.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|x86.ActiveCfg = Release|Any CPU
{0B12A079-B2DB-42B9-8A8E-AA5CBC2B3225}.Debug|Any CPU.Build.0 = Debug|x86
{0B12A079-B2DB-42B9-8A8E-AA5CBC2B3225}.Debug|Any CPU.ActiveCfg = Debug|x86
{0B12A079-B2DB-42B9-8A8E-AA5CBC2B3225}.Debug|x86.Build.0 = Debug|x86
@ -758,6 +812,12 @@ Global @@ -758,6 +812,12 @@ Global
{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{EEF5E054-4192-4A57-8FBF-E860D808A51D} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{78CC29AC-CC79-4355-B1F2-97936DF198AC} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1}
{EC06F96A-AEEC-49D6-B03D-AB87C6EB674C} = {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1}
{A4C858C8-51B6-4265-A695-A20FCEBA1D19} = {AF5E0DC1-1FA0-4346-A436-0C817C68F7C1}

51
SharpDevelop.sln

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.3
# SharpDevelop 5.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Main", "Main", "{256F5C28-532C-44C0-8AB8-D8EC5E492E01}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -137,6 +137,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigne @@ -137,6 +137,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.EDMDesigne
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}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{D54BEB89-8CBE-475C-8BB9-836D2FD71260}"
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}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analysis", "Analysis", "{7019F43E-DFD7-4D1C-8C96-E75D55646DE7}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
@ -589,6 +601,38 @@ Global @@ -589,6 +601,38 @@ Global
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|x86.Build.0 = Release|Any CPU
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|x86.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|x86.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|x86.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|x86.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|x86.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|x86.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|x86.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|x86.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|x86.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|x86.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|x86.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|x86.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|x86.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|x86.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|x86.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -650,6 +694,11 @@ Global @@ -650,6 +694,11 @@ Global
{5C70D6AB-0A33-43F9-B8B5-54558C35BBB1} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{EEF5E054-4192-4A57-8FBF-E860D808A51D} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{D54BEB89-8CBE-475C-8BB9-836D2FD71260} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{78CC29AC-CC79-4355-B1F2-97936DF198AC} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{1F261725-6318-4434-A1B1-6C70CE4CD324} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
{3EAA45A9-735C-4AC7-A799-947B93EA449D} = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}
44FA68C9-DAD1-4C3C-90BB-3435F0D1D128 = {7019F43E-DFD7-4D1C-8C96-E75D55646DE7}

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

@ -279,5 +279,6 @@ @@ -279,5 +279,6 @@
<CSharpCodeActionProvider class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseExplicitTypeAction" />
<CSharpCodeActionProvider class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseStringFormatAction" />
<CSharpCodeActionProvider class = "ICSharpCode.NRefactory.CSharp.Refactoring.UseVarKeywordAction" />
<Class class="CSharpBinding.Refactoring.MoveTypeToFileContextAction" />
</Path>
</AddIn>

2
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj

@ -74,6 +74,7 @@ @@ -74,6 +74,7 @@
<Compile Include="Src\Completion\SegmentTrackingOutputFormatter.cs" />
<Compile Include="Src\FormattingStrategy\CSharpFormatter.cs" />
<Compile Include="Src\Parser\FoldingVisitor.cs" />
<Compile Include="Src\Refactoring\CSharpCodeGenerator.cs" />
<Compile Include="Src\Refactoring\CSharpSyntaxIssue.cs" />
<Compile Include="Src\Refactoring\InsertionPoint.cs" />
<Compile Include="Src\Refactoring\IssueOptions.xaml.cs">
@ -83,6 +84,7 @@ @@ -83,6 +84,7 @@
<Compile Include="Src\Refactoring\CSharpContextActionWrapper.cs" />
<Compile Include="Src\Refactoring\IssueManager.cs" />
<Compile Include="Src\Refactoring\IssueOptionsViewModel.cs" />
<Compile Include="Src\Refactoring\MoveTypeToFileContextAction.cs" />
<Compile Include="Src\Refactoring\SDNamingConventionService.cs" />
<Compile Include="Src\Refactoring\SDRedundantUsingIssue.cs" />
<Compile Include="Src\Refactoring\EditorScript.cs" />

11
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Project/CSharpProject.cs

@ -4,6 +4,7 @@ @@ -4,6 +4,7 @@
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@ -141,6 +142,16 @@ namespace CSharpBinding @@ -141,6 +142,16 @@ namespace CSharpBinding
{
return new CSharpCodeProvider();
}
Refactoring.CSharpCodeGenerator generator;
public override ICSharpCode.SharpDevelop.Refactoring.ICodeGenerator CodeGenerator {
get {
if (generator == null)
generator = new Refactoring.CSharpCodeGenerator(this);
return generator;
}
}
}
public class CSharpProjectBehavior : ProjectBehavior

93
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/CSharpCodeGenerator.cs

@ -0,0 +1,93 @@ @@ -0,0 +1,93 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Media.Animation;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.CSharp.Resolver;
using ICSharpCode.NRefactory.CSharp.TypeSystem;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
namespace CSharpBinding.Refactoring
{
/// <summary>
/// Description of CSharpCodeGenerator.
/// </summary>
public class CSharpCodeGenerator : ICodeGenerator
{
CSharpProject project;
ProjectEntityModelContext model;
public CSharpCodeGenerator(CSharpProject project)
{
if (project == null)
throw new ArgumentNullException("project");
this.project = project;
this.model = new ProjectEntityModelContext(project, ".cs");
}
public void AddAttribute(IEntity target, IAttribute attribute)
{
var view = SD.FileService.OpenFile(new FileName(target.Region.FileName), false);
var editor = view.GetRequiredService<ITextEditor>();
var context = SDRefactoringContext.Create(editor, CancellationToken.None);
var node = context.RootNode.GetNodeAt<EntityDeclaration>(target.Region.Begin);
var resolver = context.GetResolverStateBefore(node);
var builder = new TypeSystemAstBuilder(resolver);
editor.Document.Insert(editor.Document.GetOffset(target.BodyRegion.Begin),
PrintAst(builder.ConvertAttribute(attribute)));
}
public void InsertEventHandler(ITypeDefinition target, string name, IEvent eventDefinition, bool jumpTo)
{
IUnresolvedTypeDefinition match = null;
foreach (var part in target.Parts) {
string fileName = part.UnresolvedFile.FileName;
if (!".cs".Equals(Path.GetExtension(fileName), StringComparison.OrdinalIgnoreCase))
continue;
if (match == null || model.IsBetterPart(part, match))
match = part;
}
if (match == null) return;
var view = SD.FileService.OpenFile(new FileName(match.Region.FileName), jumpTo);
var editor = view.GetRequiredService<ITextEditor>();
var context = SDRefactoringContext.Create(editor, CancellationToken.None);
IEntity last = (IEntity)target.GetMembers().LastOrDefault() ?? (IEntity)target;
var node = context.RootNode.GetNodeAt<EntityDeclaration>(last.Region.Begin);
var resolver = context.GetResolverStateAfter(node);
var builder = new TypeSystemAstBuilder(resolver);
#warning implement code generation!
string eventHandler = "<generated code>";
editor.Document.Insert(editor.Document.GetOffset(target.Region.End), eventHandler);
}
string PrintAst(AstNode node)
{
StringBuilder sb = new StringBuilder();
CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(sb), FormattingOptionsFactory.CreateSharpDevelop());
node.AcceptVisitor(visitor);
return sb.ToString();
}
}
}

135
src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/MoveTypeToFileContextAction.cs

@ -0,0 +1,135 @@ @@ -0,0 +1,135 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using ICSharpCode.AvalonEdit.Document;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.CSharp.Refactoring;
using ICSharpCode.NRefactory.Editor;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.SharpDevelop.Refactoring;
using CSharpBinding.Parser;
namespace CSharpBinding.Refactoring
{
[ContextAction("Move type to file", Description = "Moves a selected type into a new file matching the type name.")]
public class MoveTypeToFileContextAction : ContextAction
{
public override async Task<bool> IsAvailableAsync(EditorRefactoringContext context, CancellationToken cancellationToken)
{
SyntaxTree st = await context.GetSyntaxTreeAsync().ConfigureAwait(false);
Identifier identifier = (Identifier)st.GetNodeAt(context.CaretLocation, node => node.Role == Roles.Identifier);
if (identifier == null) return false;
if (MakeValidFileName(identifier.Name).Equals(Path.GetFileNameWithoutExtension(context.FileName), StringComparison.OrdinalIgnoreCase))
return false;
if (identifier.Parent.Parent is TypeDeclaration)
return false;
ParseInformation info = await context.GetParseInformationAsync().ConfigureAwait(false);
if (info.UnresolvedFile.TopLevelTypeDefinitions.Count == 1)
return false;
return identifier.Parent is TypeDeclaration || identifier.Parent is DelegateDeclaration;
}
public override async void Execute(EditorRefactoringContext context)
{
SyntaxTree st = await context.GetSyntaxTreeAsync().ConfigureAwait(false);
ICompilation compilation = await context.GetCompilationAsync().ConfigureAwait(false);
CSharpFullParseInformation info = await context.GetParseInformationAsync().ConfigureAwait(false) as CSharpFullParseInformation;
EntityDeclaration node = (EntityDeclaration)st.GetNodeAt(context.CaretLocation, n => n is TypeDeclaration || n is DelegateDeclaration);
IDocument document = context.Editor.Document;
string newFileName = Path.Combine(Path.GetDirectoryName(context.FileName), MakeValidFileName(node.Name));
string header = CopyFileHeader(document, info);
string footer = CopyFileEnd(document, info);
AstNode newNode = node.Clone();
foreach (var ns in node.Ancestors.OfType<NamespaceDeclaration>()) {
var newNS = new NamespaceDeclaration(ns.Name);
newNS.Members.AddRange(ns.Children.Where(ch => ch is UsingDeclaration
|| ch is UsingAliasDeclaration
|| ch is ExternAliasDeclaration).Select(usingDecl => usingDecl.Clone()));
newNS.AddMember(newNode);
newNode = newNS;
}
var topLevelUsings = st.Children.Where(ch => ch is UsingDeclaration
|| ch is UsingAliasDeclaration
|| ch is ExternAliasDeclaration);
StringBuilder newCode = new StringBuilder(header);
CSharpOutputVisitor visitor = new CSharpOutputVisitor(new StringWriter(newCode), FormattingOptionsFactory.CreateSharpDevelop());
foreach (var topLevelUsing in topLevelUsings)
topLevelUsing.AcceptVisitor(visitor);
newNode.AcceptVisitor(visitor);
newCode.AppendLine(footer);
IViewContent viewContent = FileService.NewFile(newFileName, newCode.ToString());
viewContent.PrimaryFile.SaveToDisk(newFileName);
// now that the code is saved in the other file, remove it from the original document
RemoveExtractedNode();
IProject project = (IProject)compilation.GetProject();
if (project != null) {
FileProjectItem projectItem = new FileProjectItem(project, ItemType.Compile);
projectItem.FileName = newFileName;
ProjectService.AddProjectItem(project, projectItem);
FileService.FireFileCreated(newFileName, false);
project.Save();
ProjectBrowserPad.RefreshViewAsync();
}
}
void RemoveExtractedNode()
{
//throw new NotImplementedException();
}
string CopyFileHeader(IDocument document, CSharpFullParseInformation info)
{
var lastHeadNode = info.SyntaxTree.Children
.TakeWhile(node => node.NodeType == NodeType.Whitespace && (!(node is Comment) || !((Comment)node).IsDocumentation))
.LastOrDefault();
if (lastHeadNode == null)
return "";
return document.GetText(0, document.GetOffset(lastHeadNode.EndLocation));
}
string CopyFileEnd(IDocument document, CSharpFullParseInformation info)
{
var firstFootNode = info.SyntaxTree.Children.Reverse()
.TakeWhile(node => node.NodeType == NodeType.Whitespace && (!(node is Comment) || !((Comment)node).IsDocumentation))
.LastOrDefault();
if (firstFootNode == null)
return "";
int offset = document.GetOffset(firstFootNode.StartLocation);
return document.GetText(offset, document.TextLength - offset);
}
string MakeValidFileName(string name)
{
if (name == null)
throw new ArgumentNullException("name");
if (name.IndexOfAny(Path.GetInvalidFileNameChars()) > -1)
return name.RemoveAny(Path.GetInvalidFileNameChars()) + ".cs";
return name + ".cs";
}
public override string DisplayName {
get { return "Move type to file"; }
}
}
}

6
src/AddIns/BackendBindings/XamlBinding/XamlBinding/XamlResolver.cs

@ -136,7 +136,9 @@ namespace ICSharpCode.XamlBinding @@ -136,7 +136,9 @@ namespace ICSharpCode.XamlBinding
ResolveResult ResolveAttributeValue(IMember propertyOrEvent, AXmlAttribute attribute)
{
IType type = parseInfo.UnresolvedFile.GetTopLevelTypeDefinition(location).Resolve(new SimpleTypeResolveContext(compilation.MainAssembly));
IUnresolvedTypeDefinition typeDefinition = parseInfo.UnresolvedFile.GetTopLevelTypeDefinition(location);
if (typeDefinition != null) {
IType type = typeDefinition.Resolve(new SimpleTypeResolveContext(compilation.MainAssembly));
if (propertyOrEvent is IEvent) {
var memberLookup = new MemberLookup(type.GetDefinition(), compilation.MainAssembly);
var rr = memberLookup.Lookup(new ThisResolveResult(type), attribute.Value, EmptyList<IType>.Instance, false);
@ -163,6 +165,8 @@ namespace ICSharpCode.XamlBinding @@ -163,6 +165,8 @@ namespace ICSharpCode.XamlBinding
}
return new UnknownMemberResolveResult(type, attribute.Value, EmptyList<IType>.Instance);
}
return ErrorResolveResult.UnknownError;
}
ITypeReference CreateTypeReference(string @namespace, string localName)
{

70
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/AbstractEventHandlerService.cs

@ -4,35 +4,32 @@ @@ -4,35 +4,32 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows.Controls;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.WpfDesign;
namespace ICSharpCode.WpfDesign.AddIn
{
abstract class AbstractEventHandlerService : IEventHandlerService
class SharpDevelopEventHandlerService : IEventHandlerService
{
WpfViewContent viewContent;
protected AbstractEventHandlerService(WpfViewContent viewContent)
public SharpDevelopEventHandlerService(WpfViewContent viewContent)
{
if (viewContent == null)
throw new ArgumentNullException("viewContent");
this.viewContent = viewContent;
}
protected IProjectContent GetProjectContent()
{
IProject p = FindProjectContainingFile();
if (p != null)
return ParserService.GetProjectContent(p) ?? ParserService.DefaultProjectContent;
else
return ParserService.DefaultProjectContent;
}
IProject FindProjectContainingFile()
{
if (ProjectService.OpenSolution != null) {
@ -41,50 +38,48 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -41,50 +38,48 @@ namespace ICSharpCode.WpfDesign.AddIn
return null;
}
protected IClass GetDesignedClass()
protected IType GetDesignedClass(ICompilation compilation)
{
Designer.Xaml.XamlDesignContext xamlContext = viewContent.DesignContext as Designer.Xaml.XamlDesignContext;
var xamlContext = viewContent.DesignContext as Designer.Xaml.XamlDesignContext;
if (xamlContext != null) {
string className = xamlContext.ClassName;
if (!string.IsNullOrEmpty(className)) {
return GetProjectContent().GetClass(className, 0);
return compilation.FindType(Type.GetType(className));
}
}
return null;
}
protected IClass GetDesignedClassCodeBehindPart(IClass c)
{
CompoundClass compound = c as CompoundClass;
if (compound != null) {
c = null;
foreach (IClass part in compound.Parts) {
if (string.IsNullOrEmpty(part.CompilationUnit.FileName))
continue;
if (".xaml".Equals(Path.GetExtension(part.CompilationUnit.FileName), StringComparison.OrdinalIgnoreCase))
continue;
if (c == null || c.CompilationUnit.FileName.Length > part.CompilationUnit.FileName.Length)
c = part;
}
}
return c;
}
protected abstract void CreateEventHandlerInternal(Type eventHandlerType, string handlerName);
public void CreateEventHandler(DesignItemProperty eventProperty)
{
var item = eventProperty.DesignItem;
string handlerName = (string)eventProperty.ValueOnInstance;
if (string.IsNullOrEmpty(handlerName)) {
var item = eventProperty.DesignItem;
if (string.IsNullOrEmpty(item.Name)) {
GenerateName(eventProperty.DesignItem);
}
handlerName = item.Name + "_" + eventProperty.Name;
eventProperty.SetValue(handlerName);
}
CreateEventHandlerInternal(eventProperty.ReturnType, handlerName);
IType t = GetDesignedClass(SD.ParserService.GetCompilation(FindProjectContainingFile()));
if (t != null) {
IMethod method = t.GetMethods(m => m.Name == handlerName).FirstOrDefault();
if (method != null) {
FileService.JumpToFilePosition(method.Region.FileName,
method.Region.BeginLine, method.Region.BeginColumn);
return;
}
}
IProject p = FindProjectContainingFile();
ITypeDefinition c = t.GetDefinition();
if (p != null && c != null) {
var e = FindEventDeclaration(c.Compilation, eventProperty.DeclaringType, eventProperty.Name);
p.CodeGenerator.InsertEventHandler(c, handlerName, e, true);
}
}
public DesignItemProperty GetDefaultEvent(DesignItem item)
@ -118,5 +113,10 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -118,5 +113,10 @@ namespace ICSharpCode.WpfDesign.AddIn
}
}
}
IEvent FindEventDeclaration(ICompilation compilation, Type declaringType, string name)
{
return compilation.FindType(declaringType).GetEvents(ue => ue.Name == name).FirstOrDefault();
}
}
}

42
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/CSharpEventHandlerService.cs

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
namespace ICSharpCode.WpfDesign.AddIn
{
sealed class CSharpEventHandlerService : AbstractEventHandlerService
{
public CSharpEventHandlerService(WpfViewContent viewContent) : base(viewContent)
{
}
protected override void CreateEventHandlerInternal(Type eventHandlerType, string handlerName)
{
IClass c = GetDesignedClass();
if (c != null) {
foreach (IMethod m in c.Methods) {
if (m.Name == handlerName) {
FileService.JumpToFilePosition(m.DeclaringType.CompilationUnit.FileName,
m.Region.BeginLine, m.Region.BeginColumn);
return;
}
}
}
c = GetDesignedClassCodeBehindPart(c);
if (c != null) {
ITextEditorProvider tecp = FileService.OpenFile(c.CompilationUnit.FileName) as ITextEditorProvider;
if (tecp != null) {
int lineNumber;
FormsDesigner.CSharpDesignerGenerator.CreateComponentEvent(
c, tecp.TextEditor, eventHandlerType, handlerName, null,
out lineNumber);
tecp.TextEditor.JumpTo(lineNumber, 0);
}
}
}
}
}

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/FileUriContext.cs

@ -2,10 +2,9 @@ @@ -2,10 +2,9 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.IO;
using System.Windows.Markup;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.WpfDesign.AddIn
{

32
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/IdeChooseClassService.cs

@ -2,13 +2,12 @@ @@ -2,13 +2,12 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.WpfDesign.AddIn
@ -16,37 +15,18 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -16,37 +15,18 @@ namespace ICSharpCode.WpfDesign.AddIn
//TODO
public class IdeChooseClassService : ChooseClassServiceBase
{
static string GetAssemblyPath(IProjectContent projectContent)
{
var r = projectContent as ReflectionProjectContent;
if (r != null) {
return r.RealAssemblyLocation;
}
var p = projectContent.Project as IProject;
if (p != null) {
return p.OutputAssemblyFullPath;
}
return null;
}
static Assembly GetAssembly(IProjectContent projectContent)
{
var path = GetAssemblyPath(projectContent);
if (path != null && File.Exists(path)) {
return Assembly.LoadFile(path);
}
return null;
}
public override IEnumerable<Assembly> GetAssemblies()
{
var pc = ParserService.CurrentProjectContent;
yield break;
#warning should load all assemblies available in the current project
/*var pc = ProjectService.CurrentProject;
if (pc == null) yield break;
var a = GetAssembly(pc);
if (a != null) yield return a;
foreach (var r in pc.ThreadSafeGetReferencedContents()) {
a = GetAssembly(r);
if (a != null) yield return a;
}
} */
}
}
}

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs

@ -2,12 +2,16 @@ @@ -2,12 +2,16 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Workbench;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using TypeResolutionService = ICSharpCode.FormsDesigner.Services.TypeResolutionService;
using TypeResolutionService = ICSharpCode.SharpDevelop.Designer.TypeResolutionService;
namespace ICSharpCode.WpfDesign.AddIn
{
@ -27,9 +31,9 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -27,9 +31,9 @@ namespace ICSharpCode.WpfDesign.AddIn
public override Assembly LoadAssembly(string name)
{
if (string.IsNullOrEmpty(name)) {
IProjectContent pc = GetProjectContent(file);
IProject pc = GetProject(file);
if (pc != null) {
return this.typeResolutionService.LoadAssembly(pc);
return typeResolutionService.LoadAssembly(pc);
}
return null;
} else {
@ -43,19 +47,19 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -43,19 +47,19 @@ namespace ICSharpCode.WpfDesign.AddIn
Assembly FindAssemblyInProjectReferences(string name)
{
IProjectContent pc = GetProjectContent(file);
IProject pc = GetProject(file);
if (pc != null) {
return FindAssemblyInProjectReferences(pc, name);
}
return null;
}
Assembly FindAssemblyInProjectReferences(IProjectContent pc, string name)
Assembly FindAssemblyInProjectReferences(IProject pc, string name)
{
foreach (IProjectContent referencedProjectContent in pc.ThreadSafeGetReferencedContents()) {
if (name == referencedProjectContent.AssemblyName) {
return this.typeResolutionService.LoadAssembly(referencedProjectContent);
}
ICompilation compilation = SD.ParserService.GetCompilation(pc);
IAssembly assembly = compilation.ReferencedAssemblies.FirstOrDefault(asm => asm.AssemblyName == name);
if (assembly != null) {
return typeResolutionService.LoadAssembly(assembly);
}
return null;
}
@ -68,15 +72,12 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -68,15 +72,12 @@ namespace ICSharpCode.WpfDesign.AddIn
return copy;
}
internal static IProjectContent GetProjectContent(OpenedFile file)
internal static IProject GetProject(OpenedFile file)
{
if (ProjectService.OpenSolution != null && file != null) {
IProject p = ProjectService.OpenSolution.FindProjectContainingFile(file.FileName);
if (p != null) {
return ParserService.GetProjectContent(p);
return ProjectService.OpenSolution.FindProjectContainingFile(file.FileName);
}
}
return ParserService.DefaultProjectContent;
return null;
}
}
}

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/PropertyDescriptionService.cs

@ -5,6 +5,7 @@ using System; @@ -5,6 +5,7 @@ using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor.CodeCompletion;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.WpfDesign.AddIn
{
@ -21,7 +22,8 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -21,7 +22,8 @@ namespace ICSharpCode.WpfDesign.AddIn
public object GetDescription(DesignItemProperty property)
{
IProjectContent pc = MyTypeFinder.GetProjectContent(file);
#warning reimplement this!
/*IProjectContent pc = MyTypeFinder.GetProjectContent(file);
if (pc != null) {
// For attached Properties
if (property.DependencyFullName != null && property.Name.Contains(".")) {
@ -39,7 +41,7 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -39,7 +41,7 @@ namespace ICSharpCode.WpfDesign.AddIn
return CodeCompletionItem.ConvertDocumentation(m.Documentation);
}
}
}
}*/
return null;
}
}

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfDisplayBinding.cs

@ -3,16 +3,17 @@ @@ -3,16 +3,17 @@
using System;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using System.Xml;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.WpfDesign.AddIn
{
public class WpfPrimaryDisplayBinding : IDisplayBinding
{
public bool CanCreateContentForFile(string fileName)
public bool CanCreateContentForFile(FileName fileName)
{
return Path.GetExtension(fileName).Equals(".xaml", StringComparison.OrdinalIgnoreCase);
}
@ -22,12 +23,12 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -22,12 +23,12 @@ namespace ICSharpCode.WpfDesign.AddIn
return new WpfViewContent(file);
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
throw new NotImplementedException();
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{
throw new NotImplementedException();
}

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -8,6 +8,7 @@ using System.Diagnostics; @@ -8,6 +8,7 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Markup;
@ -18,7 +19,9 @@ using ICSharpCode.SharpDevelop; @@ -18,7 +19,9 @@ using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.SharpDevelop.Workbench;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
@ -48,7 +51,7 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -48,7 +51,7 @@ namespace ICSharpCode.WpfDesign.AddIn
}
DesignSurface designer;
List<Task> tasks = new List<Task>();
List<SDTask> tasks = new List<SDTask>();
public DesignSurface DesignSurface {
get { return designer; }
@ -84,7 +87,7 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -84,7 +87,7 @@ namespace ICSharpCode.WpfDesign.AddIn
delegate(XamlDesignContext context) {
context.Services.AddService(typeof(IUriContext), new FileUriContext(this.PrimaryFile));
context.Services.AddService(typeof(IPropertyDescriptionService), new PropertyDescriptionService(this.PrimaryFile));
context.Services.AddService(typeof(IEventHandlerService), new CSharpEventHandlerService(this));
context.Services.AddService(typeof(IEventHandlerService), new SharpDevelopEventHandlerService(this));
context.Services.AddService(typeof(ITopLevelWindowService), new WpfAndWinFormsTopLevelWindowService());
context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService());
});
@ -116,9 +119,9 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -116,9 +119,9 @@ namespace ICSharpCode.WpfDesign.AddIn
if (wasChangedInDesigner && designer.DesignContext != null) {
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.IndentChars = EditorControlService.GlobalOptions.IndentationString;
settings.IndentChars = SD.EditorControlService.GlobalOptions.IndentationString;
settings.NewLineOnAttributes = true;
using (XmlWriter xmlWriter = XmlTextWriter.Create(stream, settings)) {
using (XmlWriter xmlWriter = XmlWriter.Create(stream, settings)) {
designer.SaveDesigner(xmlWriter);
}
} else {
@ -134,14 +137,14 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -134,14 +137,14 @@ namespace ICSharpCode.WpfDesign.AddIn
void UpdateTasks(XamlErrorService xamlErrorService)
{
Debug.Assert(xamlErrorService != null);
foreach (Task task in tasks) {
foreach (SDTask task in tasks) {
TaskService.Remove(task);
}
tasks.Clear();
foreach (XamlError error in xamlErrorService.Errors) {
var task = new Task(PrimaryFile.FileName, error.Message, error.Column - 1, error.Line - 1, TaskType.Error);
var task = new SDTask(PrimaryFile.FileName, error.Message, error.Column - 1, error.Line - 1, TaskType.Error);
tasks.Add(task);
TaskService.Add(task);
}
@ -179,19 +182,20 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -179,19 +182,20 @@ namespace ICSharpCode.WpfDesign.AddIn
if (!propertyGridView.PropertyGrid.IsNameCorrect) return;
// get the XAML file
OpenedFile fileName = this.Files.FirstOrDefault(f => f.FileName.ToString().EndsWith(".xaml"));
OpenedFile fileName = this.Files.FirstOrDefault(f => f.FileName.ToString().EndsWith(".xaml", StringComparison.OrdinalIgnoreCase));
if (fileName == null) return;
// parse the XAML file
ParseInformation info = ParserService.ParseFile(fileName.FileName.ToString());
if (info == null || info.CompilationUnit == null) return;
if (info.CompilationUnit.Classes.Count != 1) return;
ParseInformation info = SD.ParserService.Parse(fileName.FileName);
if (info == null) return;
// rename the member
#warning reimplement rename!
/*
IMember member = info.CompilationUnit.Classes [0].AllMembers.FirstOrDefault(m => m.Name == propertyGridView.PropertyGrid.OldName);
if (member != null) {
FindReferencesAndRenameHelper.RenameMember(member, propertyGridView.PropertyGrid.Name);
}
}*/
}
}

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
@ -68,7 +68,6 @@ @@ -68,7 +68,6 @@
<Compile Include="Src\Commands\Remove.cs" />
<Compile Include="Src\Commands\UndoRedo.cs" />
<Compile Include="Src\Commands\ViewXaml.cs" />
<Compile Include="Src\CSharpEventHandlerService.cs" />
<Compile Include="Src\FileUriContext.cs" />
<Compile Include="Src\IdeChooseClassService.cs" />
<Compile Include="Src\ImageSourceEditor\ChooseImageDialog.xaml.cs">
@ -98,6 +97,11 @@ @@ -98,6 +97,11 @@
</ItemGroup>
<ItemGroup>
<Page Include="Src\WpfDocumentError.xaml" />
<ProjectReference Include="..\..\..\..\Libraries\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
@ -118,21 +122,11 @@ @@ -118,21 +122,11 @@
<Name>ICSharpCode.Core.WinForms</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Dom\Project\ICSharpCode.SharpDevelop.Dom.csproj">
<Project>{924EE450-603D-49C1-A8E5-4AFAA31CE6F3}</Project>
<Name>ICSharpCode.SharpDevelop.Dom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
<Project>{8035765F-D51F-4A0C-A746-2FD100E19419}</Project>
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\FormsDesigner\Project\FormsDesigner.csproj">
<Project>{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}</Project>
<Name>FormsDesigner</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin

@ -1,7 +1,6 @@ @@ -1,7 +1,6 @@
<AddIn name="WPF Designer AddIn" author="Daniel Grunwald" copyright="prj:///doc/copyright.txt" description="WPF Designer" addInManagerHidden="preinstalled">
<Manifest>
<Identity name="ICSharpCode.WpfDesigner" />
<Dependency addin="ICSharpCode.FormsDesigner" requirePreload="true" />
</Manifest>
<Runtime>
<Import assembly="ICSharpCode.WpfDesign.AddIn.dll">

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -14,14 +14,15 @@ @@ -14,14 +14,15 @@
<OutputPath>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<DocumentationFile>..\..\..\..\..\..\AddIns\DisplayBindings\WpfDesign\ICSharpCode.WpfDesign.Designer.xml</DocumentationFile>
<NoWarn>1591</NoWarn>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Main\ICSharpCode.SharpDevelop.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign>
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
<RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Performance#CA1800;-Microsoft.Performance#CA1810;-Microsoft.Performance#CA1822</CodeAnalysisRules>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>

18
src/Main/Base/Project/Designer/IDesignerTypeResolutionService.cs

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.ComponentModel.Design;
using System.Reflection;
using ICSharpCode.SharpDevelop.Project;
namespace ICSharpCode.SharpDevelop.Designer
{
/// <summary>
/// Description of IDesignerTypeResolutionService.
/// </summary>
public interface IDesignerTypeResolutionService : ITypeResolutionService
{
Assembly LoadAssembly(IProject pc);
}
}

576
src/Main/Base/Project/Designer/TypeResolutionService.cs

@ -0,0 +1,576 @@ @@ -0,0 +1,576 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Documents;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.XmlForms;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.Win32;
namespace ICSharpCode.SharpDevelop.Designer
{
public class TypeResolutionService : IDesignerTypeResolutionService
{
readonly static List<Assembly> designerAssemblies = new List<Assembly>();
// hash of file content -> Assembly
readonly static Dictionary<string, Assembly> assemblyDict = new Dictionary<string, Assembly>();
/// <summary>
/// List of assemblies used by the form designer. This static list is not an optimal solution,
/// but better than using AppDomain.CurrentDomain.GetAssemblies(). See SD2-630.
/// </summary>
public static List<Assembly> DesignerAssemblies {
get {
return designerAssemblies;
}
}
static TypeResolutionService()
{
ClearMixedAssembliesTemporaryFiles();
DesignerAssemblies.Add(typeof(object).Assembly);
DesignerAssemblies.Add(typeof(Uri).Assembly);
DesignerAssemblies.Add(typeof(System.Drawing.Point).Assembly);
DesignerAssemblies.Add(typeof(System.Windows.Forms.Design.AnchorEditor).Assembly);
RegisterVSDesignerWorkaround();
AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolveEventHandler;
}
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
private static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, int dwFlags);
const int MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004;
static void MarkFileToDeleteOnReboot(string fileName)
{
MoveFileEx(fileName, null, MOVEFILE_DELAY_UNTIL_REBOOT);
}
static void ClearMixedAssembliesTemporaryFiles()
{
string[] files = Directory.GetFiles(Path.GetTempPath(), "*.sd_forms_designer_mixed_assembly.dll");
foreach (string fileName in files) {
try {
File.Delete(fileName);
} catch {}
}
/* We don't need to debug controls inside the forms designer
files = Directory.GetFiles(Path.GetTempPath(), "*.pdb");
foreach (string fileName in files) {
try {
File.Delete(fileName);
} catch {}
}*/
}
string formSourceFileName;
IProject callingProject;
/// <summary>
/// Dictionary of file name -> hash of loaded assemblies for the currently designed document.
/// Used to detect changes in references assemblies.
/// </summary>
readonly Dictionary<string, string> loadedAssembliesForCurrentDocument = new Dictionary<string, string>(StringComparer.Ordinal);
/// <summary>
/// Gets the project content of the project that created this TypeResolutionService.
/// Returns null when no calling project was specified.
/// </summary>
public IProject CallingProject {
get {
if (formSourceFileName != null) {
if (ProjectService.OpenSolution != null) {
return ProjectService.OpenSolution.FindProjectContainingFile(formSourceFileName);
}
formSourceFileName = null;
}
return callingProject;
}
}
public TypeResolutionService()
{
}
public TypeResolutionService(string formSourceFileName)
{
this.formSourceFileName = formSourceFileName;
}
readonly HashSet<IProject> projectContentsCurrentlyLoadingAssembly = new HashSet<IProject>();
/// <summary>
/// Loads the assembly represented by the project content. Returns null on failure.
/// </summary>
public Assembly LoadAssembly(IProject pc)
{
SD.MainThread.VerifyAccess();
// prevent StackOverflow when project contents have cyclic dependencies
// Very popular example of cyclic dependency: System <-> System.Xml
if (!projectContentsCurrentlyLoadingAssembly.Add(pc))
return null;
Assembly sdAssembly;
if (IsSharpDevelopAssembly(pc.ProjectContent, out sdAssembly))
return sdAssembly;
ICompilation compilation = SD.ParserService.GetCompilation(pc);
try {
// load dependencies of current assembly
foreach (IAssembly asm in compilation.ReferencedAssemblies) {
LoadAssembly(asm);
}
} finally {
projectContentsCurrentlyLoadingAssembly.Remove(pc);
}
return LoadAssembly(pc.OutputAssemblyFullPath);
}
public Assembly LoadAssembly(IAssembly asm)
{
var project = asm.GetProject();
if (project != null)
return LoadAssembly(project);
if (asm.IsGacAssembly())
return LoadAssembly(new AssemblyName(asm.FullAssemblyName), false);
return LoadAssembly(asm.GetRuntimeAssemblyLocation());
}
readonly string sharpDevelopRoot = Directory.GetParent(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)).FullName;
bool IsSharpDevelopAssembly(IUnresolvedAssembly pc, out Assembly assembly)
{
assembly = null;
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) {
if (!asm.IsDynamic && asm.Location.StartsWith(sharpDevelopRoot, StringComparison.OrdinalIgnoreCase) && pc.AssemblyName == asm.GetName().Name) {
assembly = asm;
return true;
}
}
return false;
}
static string GetHash(string fileName)
{
return Path.GetFileName(fileName).ToLowerInvariant() + File.GetLastWriteTimeUtc(fileName).Ticks.ToString();
}
static string GetOriginalAssemblyFullPath(Assembly asm)
{
if (asm == null) throw new ArgumentNullException("asm");
try {
return new Uri(asm.CodeBase, UriKind.Absolute).LocalPath;
} catch (UriFormatException ex) {
LoggingService.Warn("Could not determine path for assembly '" + asm.ToString() + "', CodeBase='" + asm.CodeBase + "': " + ex.Message);
return asm.Location;
} catch (InvalidOperationException ex) {
LoggingService.Warn("Could not determine path for assembly '" + asm.ToString() + "', CodeBase='" + asm.CodeBase + "': " + ex.Message);
return asm.Location;
}
}
/// <summary>
/// Loads the file in none-locking mode. Returns null on failure.
/// </summary>
public Assembly LoadAssembly(string fileName)
{
if (!File.Exists(fileName))
return null;
// FIX for SD2-716, remove when designer gets its own AppDomain
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
try {
if (string.Equals(GetOriginalAssemblyFullPath(asm), fileName, StringComparison.OrdinalIgnoreCase)) {
RegisterAssembly(asm);
return asm;
}
} catch (NotSupportedException) {
// Fixes forum-12823
}
}
string hash = GetHash(fileName);
lock (assemblyDict) {
Assembly asm;
if (assemblyDict.TryGetValue(hash, out asm))
return asm;
LoggingService.Debug("Loading assembly " + fileName + " (hash " + hash + ")");
try {
asm = Assembly.Load(File.ReadAllBytes(fileName));
} catch (BadImageFormatException e) {
if (e.Message.Contains("HRESULT: 0x8013141D")) {
LoggingService.Debug("Get HRESULt 0x8013141D, loading netmodule");
//netmodule
string tempPath = Path.GetTempFileName();
File.Delete(tempPath);
tempPath += ".sd_forms_designer_netmodule_assembly.dll";
try {
//convert netmodule to assembly
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = Path.GetDirectoryName(typeof(object).Module.FullyQualifiedName) + Path.DirectorySeparatorChar + "al.exe";
p.StartInfo.Arguments = "\"" + fileName +"\" /out:\"" + tempPath + "\"";
p.StartInfo.CreateNoWindow = true;
p.Start();
p.WaitForExit();
if(p.ExitCode == 0 && File.Exists(tempPath)) {
byte[] asm_data = File.ReadAllBytes(tempPath);
asm = Assembly.Load(asm_data);
asm.LoadModule(Path.GetFileName(fileName), File.ReadAllBytes(fileName));
}
} catch (Exception ex) {
MessageService.ShowException(ex, "Error calling linker for netmodule");
}
try {
File.Delete(tempPath);
} catch {}
} else {
// Show other load errors in the compiler message view,
// but do not prevent the designer from loading.
// The error might be caused by an assembly that is
// not even needed for the designer to load.
LoggingService.Error("Error loading assembly " + fileName, e);
WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView)).BringPadToFront();
TaskService.BuildMessageViewCategory.AppendText(
StringParser.Parse("${res:FileUtilityService.ErrorWhileLoading}")
+ "\r\n" + fileName + "\r\n" + e.Message + "\r\n"
);
return null;
}
} catch (FileLoadException e) {
if (e.Message.Contains("HRESULT: 0x80131402")) {
LoggingService.Debug("Get HRESULt 0x80131402, loading mixed modes asm from disk");
//this is C++/CLI Mixed assembly which can only be loaded from disk, not in-memory
string tempPath = Path.GetTempFileName();
File.Delete(tempPath);
tempPath += ".sd_forms_designer_mixed_assembly.dll";
File.Copy(fileName, tempPath);
/* We don't need to debug controls inside the forms designer
string pdbpath = Path.GetDirectoryName(fileName) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(fileName) + ".pdb";
if (File.Exists(pdbpath)) {
string newpdbpath = Path.GetTempPath() + Path.DirectorySeparatorChar + Path.GetFileName(pdbpath);
try {
File.Copy(pdbpath, newpdbpath);
MarkFileToDeleteOnReboot(newpdbpath);
} catch {
}
}
*/
asm = Assembly.LoadFile(tempPath);
MarkFileToDeleteOnReboot(tempPath);
} else if (e.Message.Contains("HRESULT: 0x80131019")) {
LoggingService.Debug(e.Message);
LoggingService.Debug("Attempting to load unverifiable assembly. Ignoring.");
return null;
} else {
throw; // don't ignore other load errors
}
}
lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Insert(0, asm);
}
lock (this.loadedAssembliesForCurrentDocument) {
this.loadedAssembliesForCurrentDocument[fileName] = hash;
}
assemblyDict[hash] = asm;
return asm;
}
}
void RegisterAssembly(Assembly asm)
{
string file = GetOriginalAssemblyFullPath(asm);
if (!String.IsNullOrEmpty(file)) {
string hash = GetHash(file);
lock (assemblyDict) {
assemblyDict[hash] = asm;
}
lock (this.loadedAssembliesForCurrentDocument) {
this.loadedAssembliesForCurrentDocument[file] = hash;
}
}
lock (designerAssemblies) {
if (!designerAssemblies.Contains(asm))
designerAssemblies.Insert(0, asm);
}
}
public Assembly GetAssembly(AssemblyName name)
{
return LoadAssembly(name, false);
}
public Assembly GetAssembly(AssemblyName name, bool throwOnError)
{
return LoadAssembly(name, throwOnError);
}
Assembly LoadAssembly(AssemblyName name, bool throwOnError)
{
try {
Assembly asm = Assembly.Load(name);
RegisterAssembly(asm);
return asm;
} catch (System.IO.FileLoadException) {
if (throwOnError)
throw;
return null;
}
}
public string GetPathOfAssembly(AssemblyName name)
{
Assembly assembly = GetAssembly(name);
if (assembly != null) {
return GetOriginalAssemblyFullPath(assembly);
}
return null;
}
public Type GetType(string name)
{
return GetType(name, false, false);
}
public Type GetType(string name, bool throwOnError)
{
return GetType(name, throwOnError, false);
}
#if DEBUG
int count = 0;
#endif
Dictionary<string, Type> typeCache = new Dictionary<string, Type>(StringComparer.Ordinal);
Dictionary<string, Type> typeCacheIgnoreCase = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
public void ClearCaches()
{
typeCacheIgnoreCase.Clear();
typeCache.Clear();
}
public Type GetType(string name, bool throwOnError, bool ignoreCase)
{
if (string.IsNullOrEmpty(name)) {
return null;
}
if (IgnoreType(name)) {
return null;
}
if (ignoreCase) {
Type cachedType;
if (typeCacheIgnoreCase.TryGetValue(name, out cachedType))
return cachedType;
} else {
Type cachedType;
if (typeCache.TryGetValue(name, out cachedType))
return cachedType;
}
#if DEBUG
if (!name.StartsWith("System.", StringComparison.Ordinal)) {
count++;
LoggingService.Debug(count + " TypeResolutionService: Looking for " + name);
}
#endif
try {
Type type = Type.GetType(name, false, ignoreCase);
if (type == null) {
IProject p = CallingProject;
if (p != null) {
ICompilation compilation = SD.ParserService.GetCompilation(p);
ITypeDefinition definition = ReflectionHelper.ParseReflectionName(name)
.Resolve(compilation).GetDefinition();
if (definition != null) {
Assembly assembly = LoadAssembly(definition.ParentAssembly);
if (assembly != null) {
type = assembly.GetType(name, false, ignoreCase);
}
}
}
}
// type lookup for typename, assembly, xyz style lookups
if (type == null) {
int idx = name.IndexOf(",", StringComparison.Ordinal);
if (idx > 0) {
string[] splitName = name.Split(',');
string typeName = splitName[0];
string assemblyName = splitName[1].Substring(1);
Assembly assembly = null;
try {
assembly = Assembly.Load(assemblyName);
} catch (Exception e) {
LoggingService.Error(e);
}
if (assembly != null) {
string fileName = GetOriginalAssemblyFullPath(assembly);
if (!String.IsNullOrEmpty(fileName)) {
lock (loadedAssembliesForCurrentDocument) {
loadedAssembliesForCurrentDocument [fileName] = GetHash(fileName);
}
}
lock (designerAssemblies) {
if (!designerAssemblies.Contains(assembly))
designerAssemblies.Add(assembly);
}
type = assembly.GetType(typeName, false, ignoreCase);
} else {
type = Type.GetType(typeName, false, ignoreCase);
}
}
}
if (type == null) {
lock (designerAssemblies) {
foreach (Assembly asm in DesignerAssemblies) {
try {
Type t = asm.GetType(name, false);
if (t != null) {
AddToCache(name, t, ignoreCase);
return t;
}
} catch (FileNotFoundException) {
} catch (FileLoadException) {
} catch (BadImageFormatException) {
// ignore assembly load errors
}
}
}
}
if (throwOnError && type == null)
throw new TypeLoadException(name + " not found by TypeResolutionService");
AddToCache(name, type, ignoreCase);
return type;
} catch (Exception e) {
LoggingService.Error(e);
}
return null;
}
void AddToCache(string name, Type type, bool ignoreCase)
{
if (type == null)
return;
if (ignoreCase) {
typeCacheIgnoreCase.Add(name, type);
} else {
typeCache.Add(name, type);
}
}
public void ReferenceAssembly(AssemblyName name)
{
ICSharpCode.Core.LoggingService.Warn("TODO: Add Assembly reference : " + name);
}
/// <summary>
/// Gets whether an assembly referenced by the currently designed document
/// has been changed since it has been loaded.
/// </summary>
public bool ReferencedAssemblyChanged {
get {
return this.loadedAssembliesForCurrentDocument.Any(
pair => !File.Exists(pair.Key) || !String.Equals(pair.Value, GetHash(pair.Key), StringComparison.Ordinal)
);
}
}
#region VSDesigner workarounds
/// <summary>
/// HACK - Ignore any requests for types from the Microsoft.VSDesigner
/// assembly. There are smart tag problems if data adapter
/// designers are used from this assembly.
/// </summary>
bool IgnoreType(string name)
{
int idx = name.IndexOf(",");
if (idx > 0) {
string[] splitName = name.Split(',');
string assemblyName = splitName[1].Substring(1);
if (assemblyName == "Microsoft.VSDesigner") {
return true;
}
}
return false;
}
static string vsDesignerIdeDir;
static void RegisterVSDesignerWorkaround()
{
if (vsDesignerIdeDir == null) {
vsDesignerIdeDir = "";
try {
using(RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\8.0\Setup\VS")) {
if (key != null) {
vsDesignerIdeDir = key.GetValue("VS7CommonDir") as string ?? "";
}
}
} catch (System.Security.SecurityException) {
// registry access might be denied
}
if (vsDesignerIdeDir.Length > 0) {
vsDesignerIdeDir = Path.Combine(vsDesignerIdeDir, "IDE");
AppDomain.CurrentDomain.AssemblyResolve += delegate(object sender, ResolveEventArgs args) {
string shortName = args.Name;
if (shortName.IndexOf(',') >= 0) {
shortName = shortName.Substring(0, shortName.IndexOf(','));
}
if (shortName.StartsWith("Microsoft.")
&& File.Exists(Path.Combine(vsDesignerIdeDir, shortName + ".dll")))
{
return Assembly.LoadFrom(Path.Combine(vsDesignerIdeDir, shortName + ".dll"));
}
return null;
};
}
}
}
#endregion
static Assembly AssemblyResolveEventHandler(object sender, ResolveEventArgs args)
{
LoggingService.Debug("TypeResolutionService: AssemblyResolveEventHandler: " + args.Name);
Assembly lastAssembly = null;
foreach (Assembly asm in TypeResolutionService.DesignerAssemblies) {
if (asm.FullName == args.Name) {
return asm;
}
}
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
if (asm.FullName == args.Name) {
lastAssembly = asm;
}
}
if (lastAssembly != null) {
TypeResolutionService.DesignerAssemblies.Add(lastAssembly);
LoggingService.Info("ICSharpAssemblyResolver found..." + args.Name);
}
return lastAssembly;
}
}
}

14
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -95,6 +95,8 @@ @@ -95,6 +95,8 @@
<Compile Include="..\..\ICSharpCode.SharpDevelop.BuildWorker\ExtendedBinaryReader.cs">
<Link>Src\Project\MSBuildEngine\ExtendedBinaryReader.cs</Link>
</Compile>
<Compile Include="Designer\IDesignerTypeResolutionService.cs" />
<Compile Include="Designer\TypeResolutionService.cs" />
<Compile Include="Dom\ConcatModelCollection.cs" />
<Compile Include="Dom\FilterModelCollection.cs" />
<Compile Include="Dom\IEntityModelContext.cs" />
@ -163,6 +165,7 @@ @@ -163,6 +165,7 @@
<Compile Include="Project\Build\IBuildService.cs" />
<Compile Include="Project\Build\MultipleProjectBuildable.cs" />
<Compile Include="Project\Build\ProjectBuildOptions.cs" />
<Compile Include="Refactoring\ICodeGenerator.cs" />
<Compile Include="Services\IClipboard.cs" />
<Compile Include="Services\IMessageLoop.cs" />
<Compile Include="Services\SD.cs" />
@ -504,10 +507,10 @@ @@ -504,10 +507,10 @@
<Compile Include="Src\Project\ProjectUpgradeException.cs" />
<Compile Include="Src\Project\Solution\Project_TypeGuids.cs" />
<Compile Include="Src\Project\TargetFramework.cs" />
<Compile Include="Src\Refactoring\ContextAction.cs" />
<Compile Include="Src\Refactoring\EditorRefactoringContext.cs" />
<Compile Include="Src\Refactoring\IContextAction.cs" />
<Compile Include="Src\Refactoring\IContextActionProvider.cs" />
<Compile Include="Refactoring\ContextAction.cs" />
<Compile Include="Refactoring\EditorRefactoringContext.cs" />
<Compile Include="Refactoring\IContextAction.cs" />
<Compile Include="Refactoring\IContextActionProvider.cs" />
<Compile Include="Src\Services\AmbienceService\DefaultAmbience.cs" />
<Compile Include="Src\Services\ClassBrowserIcons\ImageSourceImage.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />
@ -829,6 +832,7 @@ @@ -829,6 +832,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Designer" />
<Folder Include="Workbench\DisplayBinding" />
<Page Include="Editor\Bookmarks\BookmarkPadContent.xaml" />
<Page Include="Src\Editor\CodeCompletion\CodeCompletionPanelXaml.xaml" />
@ -891,7 +895,7 @@ @@ -891,7 +895,7 @@
<Folder Include="WinForms" />
<Folder Include="Workbench" />
<Folder Include="Src\Gui\Dialogs\ReferenceDialog\ServiceReference" />
<Folder Include="Src\Refactoring" />
<Folder Include="Refactoring" />
<Folder Include="Src\Project\Behaviors" />
<Folder Include="Src\Project\PortableLibrary" />
<Folder Include="themes" />

0
src/Main/Base/Project/Src/Refactoring/ContextAction.cs → src/Main/Base/Project/Refactoring/ContextAction.cs

0
src/Main/Base/Project/Src/Refactoring/EditorRefactoringContext.cs → src/Main/Base/Project/Refactoring/EditorRefactoringContext.cs

18
src/Main/Base/Project/Refactoring/ICodeGenerator.cs

@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.SharpDevelop.Refactoring
{
/// <summary>
/// Description of ICodeGenerator.
/// </summary>
public interface ICodeGenerator
{
void AddAttribute(IEntity target, IAttribute attribute);
void InsertEventHandler(ITypeDefinition target, string name, IEvent eventDefinition, bool jumpTo);
}
}

0
src/Main/Base/Project/Src/Refactoring/IContextAction.cs → src/Main/Base/Project/Refactoring/IContextAction.cs

0
src/Main/Base/Project/Src/Refactoring/IContextActionProvider.cs → src/Main/Base/Project/Refactoring/IContextActionProvider.cs

4
src/Main/Base/Project/Src/Gui/Components/FontSelector.xaml.cs

@ -152,7 +152,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -152,7 +152,7 @@ namespace ICSharpCode.SharpDevelop.Gui
[ValueConversion(typeof(int), typeof(double))]
public class SDFontSizeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
throw new ArgumentNullException("value");
@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -161,7 +161,7 @@ namespace ICSharpCode.SharpDevelop.Gui
throw new NotSupportedException("Cannot convert value of type " + value.GetType());
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
throw new ArgumentNullException("value");

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

@ -19,6 +19,7 @@ using ICSharpCode.SharpDevelop.Dom; @@ -19,6 +19,7 @@ using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Gui.OptionPanels;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Refactoring;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop.Project
@ -315,6 +316,13 @@ namespace ICSharpCode.SharpDevelop.Project @@ -315,6 +316,13 @@ namespace ICSharpCode.SharpDevelop.Project
}
}
[Browsable(false)]
public virtual ICodeGenerator CodeGenerator {
get {
throw new NotSupportedException("This project does not support code generation!");
}
}
/// <summary>
/// Gets the full path of the output assembly.
/// Returns null when the project does not output any assembly.

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

@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
@ -16,6 +15,7 @@ using ICSharpCode.NRefactory.TypeSystem; @@ -16,6 +15,7 @@ using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Parser;
using ICSharpCode.SharpDevelop.Refactoring;
namespace ICSharpCode.SharpDevelop.Project
{
@ -304,6 +304,11 @@ namespace ICSharpCode.SharpDevelop.Project @@ -304,6 +304,11 @@ namespace ICSharpCode.SharpDevelop.Project
/// </remarks>
IAmbience GetAmbience();
/// <summary>
/// Returns the ICodeGenerator implementation for this project.
/// </summary>
ICodeGenerator CodeGenerator { get; }
/// <summary>
/// Prepares searching for references to the specified entity.
/// This method should calculate the amount of work to be done (e.g. using the number of files to search through),

21
src/Main/Base/Project/Util/SharpDevelopExtensions.cs

@ -380,6 +380,14 @@ namespace ICSharpCode.SharpDevelop @@ -380,6 +380,14 @@ namespace ICSharpCode.SharpDevelop
return FileName.Create(assembly.UnresolvedAssembly.Location);
}
public static bool IsGacAssembly(this IAssembly assembly)
{
if (assembly == null)
throw new ArgumentNullException("assembly");
return !(assembly.UnresolvedAssembly is IProjectContent)
&& SD.GlobalAssemblyCache.FindAssemblyInNetGac(new DomAssemblyName(assembly.FullAssemblyName)) != null;
}
/// <summary>
/// Gets the ambience for the specified compilation.
/// Never returns null.
@ -605,6 +613,19 @@ namespace ICSharpCode.SharpDevelop @@ -605,6 +613,19 @@ namespace ICSharpCode.SharpDevelop
return s.Substring(0, length) + "...";
}
/// <summary>
/// Removes any character given in the array from the given string.
/// </summary>
public static string RemoveAny(this string s, params char[] chars)
{
if (string.IsNullOrEmpty(s))
return s;
var b = new StringBuilder(s);
foreach (char ch in chars) {
b.Replace(ch.ToString(), "");
}
return b.ToString();
}
public static string Replace(this string original, string pattern, string replacement, StringComparison comparisonType)
{

Loading…
Cancel
Save