Browse Source

Merge pull request #3308 from tom-englert/dev/DependencyInjection

Migrate DI from Microsoft.VisualStudio.Composition to Microsoft.Extensions.DependencyInjection
pull/3314/head
Siegfried Pammer 2 years ago committed by GitHub
parent
commit
c3261a3c09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .editorconfig
  2. 8
      Directory.Packages.props
  3. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs
  4. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs
  5. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs
  6. 6
      ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs
  7. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs
  8. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs
  9. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs
  10. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs
  11. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs
  12. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs
  13. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs
  14. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs
  15. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs
  16. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs
  17. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs
  18. 4
      ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs
  19. 2
      ICSharpCode.ILSpyX/Analyzers/ExportAnalyzerAttribute.cs
  20. 3
      ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj
  21. 6
      ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
  22. 4
      ILSpy.ReadyToRun/ReadyToRunLanguage.cs
  23. 8
      ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
  24. 4
      ILSpy/AboutPage.cs
  25. 4
      ILSpy/Analyzers/AnalyzeCommand.cs
  26. 6
      ILSpy/Analyzers/AnalyzerTreeView.xaml.cs
  27. 4
      ILSpy/Analyzers/AnalyzerTreeViewModel.cs
  28. 4
      ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs
  29. 4
      ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs
  30. 106
      ILSpy/App.xaml.cs
  31. 6
      ILSpy/AssemblyTree/AssemblyListPane.xaml.cs
  32. 48
      ILSpy/AssemblyTree/AssemblyTreeModel.cs
  33. 5
      ILSpy/Commands/BrowseBackCommand.cs
  34. 5
      ILSpy/Commands/BrowseForwardCommand.cs
  35. 4
      ILSpy/Commands/CheckForUpdatesCommand.cs
  36. 4
      ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs
  37. 9
      ILSpy/Commands/DecompileAllCommand.cs
  38. 4
      ILSpy/Commands/DecompileCommand.cs
  39. 5
      ILSpy/Commands/DecompileInNewViewCommand.cs
  40. 4
      ILSpy/Commands/DisassembleAllCommand.cs
  41. 4
      ILSpy/Commands/ExitCommand.cs
  42. 2
      ILSpy/Commands/ExportCommandAttribute.cs
  43. 4
      ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs
  44. 6
      ILSpy/Commands/GeneratePdbContextMenuEntry.cs
  45. 4
      ILSpy/Commands/ManageAssemblyListsCommand.cs
  46. 5
      ILSpy/Commands/OpenCommand.cs
  47. 5
      ILSpy/Commands/OpenFromGacCommand.cs
  48. 6
      ILSpy/Commands/Pdb2XmlCommand.cs
  49. 5
      ILSpy/Commands/RefreshCommand.cs
  50. 8
      ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs
  51. 4
      ILSpy/Commands/SaveCodeContextMenuEntry.cs
  52. 5
      ILSpy/Commands/SaveCommand.cs
  53. 5
      ILSpy/Commands/ScopeSearchToAssembly.cs
  54. 5
      ILSpy/Commands/ScopeSearchToNamespace.cs
  55. 4
      ILSpy/Commands/SearchMsdnContextMenuEntry.cs
  56. 4
      ILSpy/Commands/SelectPdbContextMenuEntry.cs
  57. 4
      ILSpy/Commands/ShowCFGContextMenuEntry.cs
  58. 6
      ILSpy/Commands/SortAssemblyListCommand.cs
  59. 2
      ILSpy/ContextMenuEntry.cs
  60. 6
      ILSpy/Docking/CloseAllDocumentsCommand.cs
  61. 103
      ILSpy/ExportProviderAdapter.cs
  62. 44
      ILSpy/ExtensionMethods.cs
  63. 6
      ILSpy/ILSpy.csproj
  64. 4
      ILSpy/Languages/CSharpILMixedLanguage.cs
  65. 7
      ILSpy/Languages/CSharpLanguage.cs
  66. 4
      ILSpy/Languages/ILLanguage.cs
  67. 6
      ILSpy/Metadata/GoToTokenCommand.cs
  68. 4
      ILSpy/Metadata/MetadataProtocolHandler.cs
  69. 6
      ILSpy/Options/DecompilerSettingsPanel.xaml.cs
  70. 4
      ILSpy/Options/DecompilerSettingsViewModel.cs
  71. 6
      ILSpy/Options/DisplaySettingsPanel.xaml.cs
  72. 4
      ILSpy/Options/DisplaySettingsViewModel.cs
  73. 6
      ILSpy/Options/MiscSettingsPanel.xaml.cs
  74. 4
      ILSpy/Options/MiscSettingsViewModel.cs
  75. 5
      ILSpy/Options/OptionsDialog.xaml.cs
  76. 8
      ILSpy/Search/SearchPane.xaml.cs
  77. 4
      ILSpy/Search/SearchPaneModel.cs
  78. 6
      ILSpy/TextView/EditorCommands.cs
  79. 6
      ILSpy/TextView/FoldingCommands.cs
  80. 14
      ILSpy/TreeNodes/AssemblyTreeNode.cs
  81. 4
      ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs
  82. 4
      ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs
  83. 4
      ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs
  84. 4
      ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs
  85. 4
      ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs
  86. 4
      ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs
  87. 4
      ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs
  88. 4
      ILSpy/TreeNodes/ThreadingSupport.cs
  89. 4
      ILSpy/ViewModels/DebugStepsPaneModel.cs
  90. 6
      ILSpy/Views/DebugSteps.xaml.cs
  91. 4
      TestPlugin/AboutPageAddition.cs
  92. 4
      TestPlugin/ContextMenuCommand.cs
  93. 4
      TestPlugin/CustomLanguage.cs
  94. 8
      TestPlugin/CustomOptionPage.xaml.cs
  95. 4
      TestPlugin/MainMenuCommand.cs
  96. 2
      TestPlugin/Readme.txt

2
.editorconfig

@ -147,5 +147,3 @@ dotnet_naming_rule.private_fields_rule.symbols = private_fields_symbols
# MEF006: No importing constructor # MEF006: No importing constructor
dotnet_diagnostic.MEF006.severity = silent dotnet_diagnostic.MEF006.severity = silent
# MEF002: Import attributes, to be removed after final DI migration
dotnet_diagnostic.MEF002.severity = silent

8
Directory.Packages.props

@ -23,12 +23,12 @@
<PackageVersion Include="Microsoft.DiaSymReader.Native" Version="17.0.0-beta1.21524.1" /> <PackageVersion Include="Microsoft.DiaSymReader.Native" Version="17.0.0-beta1.21524.1" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" /> <PackageVersion Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" /> <PackageVersion Include="Microsoft.Extensions.Hosting" Version="8.0.1" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="Microsoft.NETCore.ILAsm" Version="8.0.0" /> <PackageVersion Include="Microsoft.NETCore.ILAsm" Version="8.0.0" />
<PackageVersion Include="Microsoft.NETCore.ILDAsm" Version="8.0.0" /> <PackageVersion Include="Microsoft.NETCore.ILDAsm" Version="8.0.0" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" /> <PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.VisualStudio.Composition" Version="17.11.13" />
<PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" /> <PackageVersion Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.135" />
<PackageVersion Include="Mono.Cecil" Version="0.11.6" /> <PackageVersion Include="Mono.Cecil" Version="0.11.6" />
<PackageVersion Include="NaturalSort.Extension" Version="4.3.0" /> <PackageVersion Include="NaturalSort.Extension" Version="4.3.0" />
@ -38,15 +38,15 @@
<PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" /> <PackageVersion Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageVersion Include="NuGet.Protocol" Version="6.11.1" /> <PackageVersion Include="NuGet.Protocol" Version="6.11.1" />
<PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" /> <PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" />
<PackageVersion Include="System.Composition.AttributedModel" Version="8.0.0" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" /> <PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.ComponentModel.Composition" Version="8.0.0" />
<PackageVersion Include="System.Composition" Version="8.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" /> <PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Reflection.Metadata" Version="8.0.1" /> <PackageVersion Include="System.Reflection.Metadata" Version="8.0.1" />
<PackageVersion Include="System.Resources.Extensions" Version="8.0.0" /> <PackageVersion Include="System.Resources.Extensions" Version="8.0.0" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" /> <PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="TomsToolbox.Composition.MicrosoftExtensions" Version="2.20.0" />
<PackageVersion Include="TomsToolbox.Wpf.Composition" Version="2.20.0" /> <PackageVersion Include="TomsToolbox.Wpf.Composition" Version="2.20.0" />
<PackageVersion Include="TomsToolbox.Wpf.Composition.Mef" Version="2.20.0" /> <PackageVersion Include="TomsToolbox.Wpf.Composition.AttributedModel" Version="2.20.0" />
<PackageVersion Include="TomsToolbox.Wpf.Styles" Version="2.20.0" /> <PackageVersion Include="TomsToolbox.Wpf.Styles" Version="2.20.0" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" /> <PackageVersion Include="coverlet.collector" Version="6.0.2" />
</ItemGroup> </ItemGroup>

4
ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Threading; using System.Threading;
@ -30,7 +30,7 @@ using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.ILSpyX.Analyzers.Builtin namespace ICSharpCode.ILSpyX.Analyzers.Builtin
{ {
[ExportAnalyzer(Header = "Applied To", Order = 10)] [ExportAnalyzer(Header = "Applied To", Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class AttributeAppliedToAnalyzer : IAnalyzer class AttributeAppliedToAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

4
ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows events that implement an interface event. /// Shows events that implement an interface event.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Implemented By", Order = 10)] [ExportAnalyzer(Header = "Implemented By", Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class EventImplementedByAnalyzer : IAnalyzer class EventImplementedByAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

4
ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows events that override an event. /// Shows events that override an event.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Overridden By", Order = 20)] [ExportAnalyzer(Header = "Overridden By", Order = 20)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class EventOverriddenByAnalyzer : IAnalyzer class EventOverriddenByAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

6
ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Finds methods where this field is read. /// Finds methods where this field is read.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Assigned By", Order = 20)] [ExportAnalyzer(Header = "Assigned By", Order = 20)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class AssignedByFieldAccessAnalyzer : FieldAccessAnalyzer class AssignedByFieldAccessAnalyzer : FieldAccessAnalyzer
{ {
public AssignedByFieldAccessAnalyzer() : base(true) { } public AssignedByFieldAccessAnalyzer() : base(true) { }
@ -46,7 +46,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Finds methods where this field is written. /// Finds methods where this field is written.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Read By", Order = 10)] [ExportAnalyzer(Header = "Read By", Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class ReadByFieldAccessAnalyzer : FieldAccessAnalyzer class ReadByFieldAccessAnalyzer : FieldAccessAnalyzer
{ {
public ReadByFieldAccessAnalyzer() : base(false) { } public ReadByFieldAccessAnalyzer() : base(false) { }

4
ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows members from all corresponding interfaces the selected member implements. /// Shows members from all corresponding interfaces the selected member implements.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Implements", Order = 40)] [ExportAnalyzer(Header = "Implements", Order = 40)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MemberImplementsInterfaceAnalyzer : IAnalyzer class MemberImplementsInterfaceAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

4
ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows methods that implement an interface method. /// Shows methods that implement an interface method.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Implemented By", Order = 40)] [ExportAnalyzer(Header = "Implemented By", Order = 40)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MethodImplementedByAnalyzer : IAnalyzer class MethodImplementedByAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

4
ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows methods that override a method. /// Shows methods that override a method.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Overridden By", Order = 30)] [ExportAnalyzer(Header = "Overridden By", Order = 30)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MethodOverriddenByAnalyzer : IAnalyzer class MethodOverriddenByAnalyzer : IAnalyzer
{ {
const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that are used by a method. /// Shows entities that are used by a method.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Used By", Order = 20)] [ExportAnalyzer(Header = "Used By", Order = 20)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MethodUsedByAnalyzer : IAnalyzer class MethodUsedByAnalyzer : IAnalyzer
{ {
const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that are used by a method. /// Shows entities that are used by a method.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Uses", Order = 10)] [ExportAnalyzer(Header = "Uses", Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MethodUsesAnalyzer : IAnalyzer class MethodUsesAnalyzer : IAnalyzer
{ {
public bool Show(ISymbol symbol) => symbol is IMethod method && method.HasBody; public bool Show(ISymbol symbol) => symbol is IMethod method && method.HasBody;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that are used by a method. /// Shows entities that are used by a method.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Used By", Order = 20)] [ExportAnalyzer(Header = "Used By", Order = 20)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MethodVirtualUsedByAnalyzer : IAnalyzer class MethodVirtualUsedByAnalyzer : IAnalyzer
{ {
const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows properties that implement an interface property. /// Shows properties that implement an interface property.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Implemented By", Order = 10)] [ExportAnalyzer(Header = "Implemented By", Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class PropertyImplementedByAnalyzer : IAnalyzer class PropertyImplementedByAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

4
ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows properties that override a property. /// Shows properties that override a property.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Overridden By", Order = 20)] [ExportAnalyzer(Header = "Overridden By", Order = 20)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class PropertyOverriddenByAnalyzer : IAnalyzer class PropertyOverriddenByAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

4
ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Finds all entities that expose a type. /// Finds all entities that expose a type.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Exposed By", Order = 40)] [ExportAnalyzer(Header = "Exposed By", Order = 40)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class TypeExposedByAnalyzer : IAnalyzer class TypeExposedByAnalyzer : IAnalyzer
{ {
public bool Show(ISymbol entity) => entity is ITypeDefinition; public bool Show(ISymbol entity) => entity is ITypeDefinition;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Finds all extension methods defined for a type. /// Finds all extension methods defined for a type.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Extension Methods", Order = 50)] [ExportAnalyzer(Header = "Extension Methods", Order = 50)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class TypeExtensionMethodsAnalyzer : IAnalyzer class TypeExtensionMethodsAnalyzer : IAnalyzer
{ {
public bool Show(ISymbol symbol) => symbol is ITypeDefinition entity && !entity.IsStatic; public bool Show(ISymbol symbol) => symbol is ITypeDefinition entity && !entity.IsStatic;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows methods that instantiate a type. /// Shows methods that instantiate a type.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Instantiated By", Order = 20)] [ExportAnalyzer(Header = "Instantiated By", Order = 20)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class TypeInstantiatedByAnalyzer : IAnalyzer class TypeInstantiatedByAnalyzer : IAnalyzer
{ {
const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions;

4
ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs

@ -19,7 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -35,7 +35,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that use a type. /// Shows entities that use a type.
/// </summary> /// </summary>
[ExportAnalyzer(Header = "Used By", Order = 30)] [ExportAnalyzer(Header = "Used By", Order = 30)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class TypeUsedByAnalyzer : IAnalyzer class TypeUsedByAnalyzer : IAnalyzer
{ {
public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context) public IEnumerable<ISymbol> Analyze(ISymbol analyzedSymbol, AnalyzerContext context)

2
ICSharpCode.ILSpyX/Analyzers/ExportAnalyzerAttribute.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;

3
ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj

@ -66,10 +66,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.ComponentModel.Composition" /> <PackageReference Include="System.Composition.AttributedModel" />
<PackageReference Include="System.Reflection.Metadata" /> <PackageReference Include="System.Reflection.Metadata" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" /> <PackageReference Include="System.Runtime.CompilerServices.Unsafe" />
<PackageReference Include="System.Composition" />
<PackageReference Include="Mono.Cecil" /> <PackageReference Include="Mono.Cecil" />
<PackageReference Include="K4os.Compression.LZ4" /> <PackageReference Include="K4os.Compression.LZ4" />
<PackageReference Include="Microsoft.SourceLink.GitHub"> <PackageReference Include="Microsoft.SourceLink.GitHub">

6
ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using ICSharpCode.BamlDecompiler; using ICSharpCode.BamlDecompiler;
@ -32,7 +32,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ILSpy.BamlDecompiler namespace ILSpy.BamlDecompiler
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public sealed class BamlResourceNodeFactory : IResourceNodeFactory public sealed class BamlResourceNodeFactory : IResourceNodeFactory
{ {
public ITreeNode CreateNode(Resource resource) public ITreeNode CreateNode(Resource resource)
@ -45,7 +45,7 @@ namespace ILSpy.BamlDecompiler
} }
[Export(typeof(IResourceFileHandler))] [Export(typeof(IResourceFileHandler))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public sealed class BamlResourceFileHandler : IResourceFileHandler public sealed class BamlResourceFileHandler : IResourceFileHandler
{ {
public string EntryType => "Page"; public string EntryType => "Page";

4
ILSpy.ReadyToRun/ReadyToRunLanguage.cs

@ -20,7 +20,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -96,7 +96,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun
#endif #endif
[Export(typeof(Language))] [Export(typeof(Language))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal class ReadyToRunLanguage : Language internal class ReadyToRunLanguage : Language
{ {
private static readonly ConditionalWeakTable<MetadataFile, ReadyToRunReaderCacheEntry> readyToRunReaders = new ConditionalWeakTable<MetadataFile, ReadyToRunReaderCacheEntry>(); private static readonly ConditionalWeakTable<MetadataFile, ReadyToRunReaderCacheEntry> readyToRunReaders = new ConditionalWeakTable<MetadataFile, ReadyToRunReaderCacheEntry>();

8
ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs

@ -16,18 +16,18 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Options; using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.Util; using ICSharpCode.ILSpy.Util;
using TomsToolbox.Wpf; using TomsToolbox.Wpf;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy.ReadyToRun namespace ICSharpCode.ILSpy.ReadyToRun
{ {
[DataTemplate(typeof(ReadyToRunOptionsViewModel))] [DataTemplate(typeof(ReadyToRunOptionsViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
partial class ReadyToRunOptionPage partial class ReadyToRunOptionPage
{ {
public ReadyToRunOptionPage() public ReadyToRunOptionPage()
@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.ReadyToRun
} }
[ExportOptionPage(Order = 40)] [ExportOptionPage(Order = 40)]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
class ReadyToRunOptionsViewModel : ObservableObject, IOptionPage class ReadyToRunOptionsViewModel : ObservableObject, IOptionPage
{ {
private ReadyToRunOptions options; private ReadyToRunOptions options;

4
ILSpy/AboutPage.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows; using System.Windows;
@ -37,7 +37,7 @@ using ICSharpCode.ILSpyX.Settings;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._About), MenuOrder = 99999)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._About), MenuOrder = 99999)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class AboutPage : SimpleCommand sealed class AboutPage : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

4
ILSpy/Analyzers/AnalyzeCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -26,7 +26,7 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {
[ExportContextMenuEntry(Header = nameof(Resources.Analyze), Icon = "Images/Search", Category = nameof(Resources.Analyze), InputGestureText = "Ctrl+R", Order = 100)] [ExportContextMenuEntry(Header = nameof(Resources.Analyze), Icon = "Images/Search", Category = nameof(Resources.Analyze), InputGestureText = "Ctrl+R", Order = 100)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class AnalyzeContextMenuCommand : IContextMenuEntry internal sealed class AnalyzeContextMenuCommand : IContextMenuEntry
{ {
private static readonly AnalyzerTreeViewModel AnalyzerTreeView = App.ExportProvider.GetExportedValue<AnalyzerTreeViewModel>(); private static readonly AnalyzerTreeViewModel AnalyzerTreeView = App.ExportProvider.GetExportedValue<AnalyzerTreeViewModel>();

6
ILSpy/Analyzers/AnalyzerTreeView.xaml.cs

@ -16,12 +16,12 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Controls; using System.Windows.Controls;
using ICSharpCode.ILSpyX.TreeView; using ICSharpCode.ILSpyX.TreeView;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpy.Analyzers
/// Interaction logic for AnalyzerTreeView.xaml /// Interaction logic for AnalyzerTreeView.xaml
/// </summary> /// </summary>
[DataTemplate(typeof(AnalyzerTreeViewModel))] [DataTemplate(typeof(AnalyzerTreeViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
[Export] [Export]
public partial class AnalyzerTreeView public partial class AnalyzerTreeView
{ {

4
ILSpy/Analyzers/AnalyzerTreeViewModel.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
@ -32,7 +32,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {
[ExportToolPane] [ExportToolPane]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
[Export] [Export]
public class AnalyzerTreeViewModel : ToolPaneModel public class AnalyzerTreeViewModel : ToolPaneModel
{ {

4
ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
@ -24,7 +24,7 @@ using System.Windows;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {
[ExportContextMenuEntry(Header = "Copy results", Category = "Analyze", Order = 200)] [ExportContextMenuEntry(Header = "Copy results", Category = "Analyze", Order = 200)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class CopyAnalysisResultsContextMenuEntry : IContextMenuEntry internal sealed class CopyAnalysisResultsContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

4
ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs

@ -16,13 +16,13 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
namespace ICSharpCode.ILSpy.Analyzers namespace ICSharpCode.ILSpy.Analyzers
{ {
[ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete", Category = "Analyze", Order = 200)] [ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete", Category = "Analyze", Order = 200)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class RemoveAnalyzeContextMenuEntry : IContextMenuEntry internal sealed class RemoveAnalyzeContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

106
ILSpy/App.xaml.cs

@ -23,7 +23,6 @@ using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.Loader; using System.Runtime.Loader;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
@ -36,8 +35,6 @@ using ICSharpCode.ILSpyX.Analyzers;
using Medo.Application; using Medo.Application;
using Microsoft.VisualStudio.Composition;
using TomsToolbox.Wpf.Styles; using TomsToolbox.Wpf.Styles;
using ICSharpCode.ILSpyX.TreeView; using ICSharpCode.ILSpyX.TreeView;
@ -47,6 +44,11 @@ using ICSharpCode.ILSpy.Themes;
using System.Globalization; using System.Globalization;
using System.Threading; using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using TomsToolbox.Composition.MicrosoftExtensions;
using TomsToolbox.Essentials;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
/// <summary> /// <summary>
@ -59,10 +61,9 @@ namespace ICSharpCode.ILSpy
public static IExportProvider ExportProvider { get; private set; } public static IExportProvider ExportProvider { get; private set; }
internal class ExceptionData internal record ExceptionData(Exception Exception)
{ {
public Exception Exception; public string PluginName { get; init; }
public string PluginName;
} }
public App() public App()
@ -80,6 +81,14 @@ namespace ICSharpCode.ILSpy
InitializeComponent(); InitializeComponent();
if (!InitializeDependencyInjection(SettingsService.Instance))
{
// There is something completely wrong with DI, probably some service registration is missing => nothing we can do to recover, so stop and shut down.
Exit += (_, _) => MessageBox.Show(StartupExceptions.FormatExceptions(), "Sorry we crashed!");
Shutdown(1);
return;
}
if (!Debugger.IsAttached) if (!Debugger.IsAttached)
{ {
AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; AppDomain.CurrentDomain.UnhandledException += ShowErrorBox;
@ -92,8 +101,6 @@ namespace ICSharpCode.ILSpy
Resources.RegisterDefaultStyles(); Resources.RegisterDefaultStyles();
InitializeMef().GetAwaiter().GetResult();
// Register the export provider so that it can be accessed from WPF/XAML components. // Register the export provider so that it can be accessed from WPF/XAML components.
ExportProviderLocator.Register(ExportProvider); ExportProviderLocator.Register(ExportProvider);
// Add data templates registered via MEF. // Add data templates registered via MEF.
@ -103,7 +110,7 @@ namespace ICSharpCode.ILSpy
ThemeManager.Current.Theme = sessionSettings.Theme; ThemeManager.Current.Theme = sessionSettings.Theme;
if (!string.IsNullOrEmpty(sessionSettings.CurrentCulture)) if (!string.IsNullOrEmpty(sessionSettings.CurrentCulture))
{ {
Thread.CurrentThread.CurrentUICulture = CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(sessionSettings.CurrentCulture); Thread.CurrentThread.CurrentUICulture = CultureInfo.DefaultThreadCurrentUICulture = new(sessionSettings.CurrentCulture);
} }
EventManager.RegisterClassHandler(typeof(Window), EventManager.RegisterClassHandler(typeof(Window),
@ -125,6 +132,13 @@ namespace ICSharpCode.ILSpy
SettingsService.Instance.AssemblyListManager.CreateDefaultAssemblyLists(); SettingsService.Instance.AssemblyListManager.CreateDefaultAssemblyLists();
} }
public new static App Current => (App)Application.Current;
public new MainWindow MainWindow {
get => (MainWindow)base.MainWindow;
set => base.MainWindow = value;
}
private static void SingleInstance_NewInstanceDetected(object sender, NewInstanceEventArgs e) => ExportProvider.GetExportedValue<AssemblyTreeModel>().HandleSingleInstanceCommandLineArguments(e.Args).HandleExceptions(); private static void SingleInstance_NewInstanceDetected(object sender, NewInstanceEventArgs e) => ExportProvider.GetExportedValue<AssemblyTreeModel>().HandleSingleInstanceCommandLineArguments(e.Args).HandleExceptions();
static Assembly ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName) static Assembly ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName)
@ -136,22 +150,17 @@ namespace ICSharpCode.ILSpy
return context.LoadFromAssemblyPath(assemblyFileName); return context.LoadFromAssemblyPath(assemblyFileName);
} }
private static async Task InitializeMef() private static bool InitializeDependencyInjection(SettingsService settingsService)
{ {
// Add custom logic for resolution of dependencies. // Add custom logic for resolution of dependencies.
// This necessary because the AssemblyLoadContext.LoadFromAssemblyPath and related methods, // This necessary because the AssemblyLoadContext.LoadFromAssemblyPath and related methods,
// do not automatically load dependencies. // do not automatically load dependencies.
AssemblyLoadContext.Default.Resolving += ResolvePluginDependencies; AssemblyLoadContext.Default.Resolving += ResolvePluginDependencies;
// Cannot show MessageBox here, because WPF would crash with a XamlParseException
// Remember and show exceptions in text output, once MainWindow is properly initialized
try try
{ {
// Set up VS MEF. For now, only do MEF1 part discovery, since that was in use before. var services = new ServiceCollection();
// To support both MEF1 and MEF2 parts, just change this to:
// var discovery = PartDiscovery.Combine(new AttributedPartDiscoveryV1(Resolver.DefaultInstance),
// new AttributedPartDiscovery(Resolver.DefaultInstance));
var discovery = new AttributedPartDiscoveryV1(Resolver.DefaultInstance);
var catalog = ComposableCatalog.Create(Resolver.DefaultInstance);
var pluginDir = Path.GetDirectoryName(typeof(App).Module.FullyQualifiedName); var pluginDir = Path.GetDirectoryName(typeof(App).Module.FullyQualifiedName);
if (pluginDir != null) if (pluginDir != null)
{ {
@ -160,46 +169,39 @@ namespace ICSharpCode.ILSpy
var name = Path.GetFileNameWithoutExtension(plugin); var name = Path.GetFileNameWithoutExtension(plugin);
try try
{ {
var asm = AssemblyLoadContext.Default.LoadFromAssemblyPath(plugin); var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(plugin);
var parts = await discovery.CreatePartsAsync(asm); services.BindExports(assembly);
catalog = catalog.AddParts(parts);
} }
catch (Exception ex) catch (Exception ex)
{ {
StartupExceptions.Add(new ExceptionData { Exception = ex, PluginName = name }); // Cannot show MessageBox here, because WPF would crash with a XamlParseException
// Remember and show exceptions in text output, once MainWindow is properly initialized
StartupExceptions.Add(new(ex) { PluginName = name });
} }
} }
} }
// Add the built-in parts: First, from ILSpyX // Add the built-in parts: First, from ILSpyX
var xParts = await discovery.CreatePartsAsync(typeof(IAnalyzer).Assembly); services.BindExports(typeof(IAnalyzer).Assembly);
catalog = catalog.AddParts(xParts);
// Then from ILSpy itself // Then from ILSpy itself
var createdParts = await discovery.CreatePartsAsync(Assembly.GetExecutingAssembly()); services.BindExports(Assembly.GetExecutingAssembly());
catalog = catalog.AddParts(createdParts); // Add the settings service
services.AddSingleton(settingsService);
// If/When the project switches to .NET Standard/Core, this will be needed to allow metadata interfaces (as opposed
// to metadata classes). When running on .NET Framework, it's automatic. var serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true });
// catalog.WithDesktopSupport();
// If/When any part needs to import ICompositionService, this will be needed: ExportProvider = new ExportProviderAdapter(serviceProvider);
// catalog.WithCompositionService();
var config = CompositionConfiguration.Create(catalog); return true;
var exportProviderFactory = config.CreateExportProviderFactory();
ExportProvider = new ExportProviderAdapter(exportProviderFactory.CreateExportProvider());
// This throws exceptions for composition failures. Alternatively, the configuration's CompositionErrors property
// could be used to log the errors directly. Used at the end so that it does not prevent the export provider setup.
config.ThrowOnErrors();
}
catch (CompositionFailedException ex) when (ex.InnerException is AggregateException agex)
{
foreach (var inner in agex.InnerExceptions)
{
StartupExceptions.Add(new ExceptionData { Exception = inner });
}
} }
catch (Exception ex) catch (Exception ex)
{ {
StartupExceptions.Add(new ExceptionData { Exception = ex }); if (ex is AggregateException aggregate)
StartupExceptions.AddRange(aggregate.InnerExceptions.Select(item => new ExceptionData(ex)));
else
StartupExceptions.Add(new(ex));
return false;
} }
} }
@ -207,15 +209,7 @@ namespace ICSharpCode.ILSpy
{ {
base.OnStartup(e); base.OnStartup(e);
var output = new StringBuilder(); MainWindow = new();
if (StartupExceptions.FormatExceptions(output))
{
MessageBox.Show(output.ToString(), "Sorry we crashed!");
Environment.Exit(1);
}
MainWindow = new MainWindow();
MainWindow.Show(); MainWindow.Show();
} }

6
ILSpy/AssemblyTree/AssemblyListPane.xaml.cs

@ -16,14 +16,14 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows; using System.Windows;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.ILSpy.ViewModels; using ICSharpCode.ILSpy.ViewModels;
using ICSharpCode.ILSpyX.TreeView; using ICSharpCode.ILSpyX.TreeView;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy.AssemblyTree namespace ICSharpCode.ILSpy.AssemblyTree
{ {
@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
/// Interaction logic for AssemblyListPane.xaml /// Interaction logic for AssemblyListPane.xaml
/// </summary> /// </summary>
[DataTemplate(typeof(AssemblyTreeModel))] [DataTemplate(typeof(AssemblyTreeModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public partial class AssemblyListPane public partial class AssemblyListPane
{ {
public AssemblyListPane() public AssemblyListPane()

48
ILSpy/AssemblyTree/AssemblyTreeModel.cs

@ -20,19 +20,18 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata.Ecma335;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Threading; using System.Windows.Threading;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Documentation; using ICSharpCode.Decompiler.Documentation;
using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -56,7 +55,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.AssemblyTree namespace ICSharpCode.ILSpy.AssemblyTree
{ {
[ExportToolPane] [ExportToolPane]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
[Export] [Export]
public class AssemblyTreeModel : ToolPaneModel public class AssemblyTreeModel : ToolPaneModel
{ {
@ -160,13 +159,15 @@ namespace ICSharpCode.ILSpy.AssemblyTree
/// Called on startup or when passed arguments via WndProc from a second instance. /// Called on startup or when passed arguments via WndProc from a second instance.
/// In the format case, spySettings is non-null; in the latter it is null. /// In the format case, spySettings is non-null; in the latter it is null.
/// </summary> /// </summary>
private void HandleCommandLineArgumentsAfterShowList(CommandLineArguments args, ISettingsProvider? spySettings = null) private async Task HandleCommandLineArgumentsAfterShowList(CommandLineArguments args, ISettingsProvider? spySettings = null)
{ {
var sessionSettings = SettingsService.Instance.SessionSettings; var sessionSettings = SettingsService.Instance.SessionSettings;
var relevantAssemblies = commandLineLoadedAssemblies.ToList(); var relevantAssemblies = commandLineLoadedAssemblies.ToList();
commandLineLoadedAssemblies.Clear(); // clear references once we don't need them anymore commandLineLoadedAssemblies.Clear(); // clear references once we don't need them anymore
NavigateOnLaunch(args.NavigateTo, sessionSettings.ActiveTreeViewPath, spySettings, relevantAssemblies);
await NavigateOnLaunch(args.NavigateTo, sessionSettings.ActiveTreeViewPath, spySettings, relevantAssemblies);
if (args.Search != null) if (args.Search != null)
{ {
var searchPane = App.ExportProvider.GetExportedValue<SearchPaneModel>(); var searchPane = App.ExportProvider.GetExportedValue<SearchPaneModel>();
@ -180,7 +181,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree
{ {
var cmdArgs = CommandLineArguments.Create(args); var cmdArgs = CommandLineArguments.Create(args);
await Dispatcher.InvokeAsync(() => { await Dispatcher.InvokeAsync(async () => {
if (!HandleCommandLineArguments(cmdArgs)) if (!HandleCommandLineArguments(cmdArgs))
return; return;
@ -192,11 +193,11 @@ namespace ICSharpCode.ILSpy.AssemblyTree
window.WindowState = WindowState.Normal; window.WindowState = WindowState.Normal;
} }
HandleCommandLineArgumentsAfterShowList(cmdArgs); await HandleCommandLineArgumentsAfterShowList(cmdArgs);
}); });
} }
private async void NavigateOnLaunch(string? navigateTo, string[]? activeTreeViewPath, ISettingsProvider? spySettings, List<LoadedAssembly> relevantAssemblies) private async Task NavigateOnLaunch(string? navigateTo, string[]? activeTreeViewPath, ISettingsProvider? spySettings, List<LoadedAssembly> relevantAssemblies)
{ {
var initialSelection = SelectedItem; var initialSelection = SelectedItem;
if (navigateTo != null) if (navigateTo != null)
@ -386,26 +387,31 @@ namespace ICSharpCode.ILSpy.AssemblyTree
Dispatcher.BeginInvoke(DispatcherPriority.Loaded, OpenAssemblies); Dispatcher.BeginInvoke(DispatcherPriority.Loaded, OpenAssemblies);
} }
private void OpenAssemblies() private async Task OpenAssemblies()
{ {
HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments, SettingsService.Instance.SpySettings); await HandleCommandLineArgumentsAfterShowList(App.CommandLineArguments, SettingsService.Instance.SpySettings);
AvalonEditTextOutput output = new(); if (FormatExceptions(App.StartupExceptions.ToArray(), out var output))
if (FormatExceptions(App.StartupExceptions.ToArray(), output))
{ {
output.Title = "Startup errors";
DockWorkspace.Instance.AddTabPage();
DockWorkspace.Instance.ShowText(output); DockWorkspace.Instance.ShowText(output);
} }
} }
private static bool FormatExceptions(App.ExceptionData[] exceptions, ITextOutput output) private static bool FormatExceptions(App.ExceptionData[] exceptions, [NotNullWhen(true)] out AvalonEditTextOutput? output)
{ {
var stringBuilder = new StringBuilder(); output = null;
var result = exceptions.FormatExceptions(stringBuilder);
if (result) var result = exceptions.FormatExceptions();
{ if (result.IsNullOrEmpty())
output.Write(stringBuilder.ToString()); return false;
}
return result; output = new();
output.Write(result);
return true;
} }
private void ShowAssemblyList(string name) private void ShowAssemblyList(string name)

5
ILSpy/Commands/BrowseBackCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
@ -25,12 +25,11 @@ using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportToolbarCommand(ToolTip = nameof(Resources.Back), ToolbarIcon = "Images/Back", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 0)] [ExportToolbarCommand(ToolTip = nameof(Resources.Back), ToolbarIcon = "Images/Back", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 0)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class BrowseBackCommand : CommandWrapper sealed class BrowseBackCommand : CommandWrapper
{ {
readonly AssemblyTreeModel assemblyTreeModel; readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public BrowseBackCommand(AssemblyTreeModel assemblyTreeModel) public BrowseBackCommand(AssemblyTreeModel assemblyTreeModel)
: base(NavigationCommands.BrowseBack) : base(NavigationCommands.BrowseBack)
{ {

5
ILSpy/Commands/BrowseForwardCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
@ -25,12 +25,11 @@ using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportToolbarCommand(ToolTip = nameof(Resources.Forward), ToolbarIcon = "Images/Forward", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 1)] [ExportToolbarCommand(ToolTip = nameof(Resources.Forward), ToolbarIcon = "Images/Forward", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 1)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class BrowseForwardCommand : CommandWrapper sealed class BrowseForwardCommand : CommandWrapper
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public BrowseForwardCommand(AssemblyTreeModel assemblyTreeModel) public BrowseForwardCommand(AssemblyTreeModel assemblyTreeModel)
: base(NavigationCommands.BrowseForward) : base(NavigationCommands.BrowseForward)
{ {

4
ILSpy/Commands/CheckForUpdatesCommand.cs

@ -17,14 +17,14 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._CheckUpdates), MenuOrder = 5000)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._CheckUpdates), MenuOrder = 5000)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class CheckForUpdatesCommand : SimpleCommand sealed class CheckForUpdatesCommand : SimpleCommand
{ {
public override bool CanExecute(object parameter) public override bool CanExecute(object parameter)

4
ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs

@ -15,7 +15,7 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows; using System.Windows;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
@ -24,7 +24,7 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportContextMenuEntry(Header = nameof(Resources.CopyName), Icon = "images/Copy", Order = 9999)] [ExportContextMenuEntry(Header = nameof(Resources.CopyName), Icon = "images/Copy", Order = 9999)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class CopyFullyQualifiedNameContextMenuEntry : IContextMenuEntry public class CopyFullyQualifiedNameContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

9
ILSpy/Commands/DecompileAllCommand.cs

@ -21,7 +21,7 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -35,13 +35,12 @@ using ICSharpCode.ILSpyX;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class DecompileAllCommand : SimpleCommand sealed class DecompileAllCommand : SimpleCommand
{ {
private readonly IReadOnlyCollection<IResourceFileHandler> resourceFileHandlers; private readonly IReadOnlyCollection<IResourceFileHandler> resourceFileHandlers;
[ImportingConstructor] public DecompileAllCommand(IEnumerable<IResourceFileHandler> resourceFileHandlers)
public DecompileAllCommand([ImportMany] IEnumerable<IResourceFileHandler> resourceFileHandlers)
{ {
this.resourceFileHandlers = resourceFileHandlers.ToArray(); this.resourceFileHandlers = resourceFileHandlers.ToArray();
} }
@ -96,7 +95,7 @@ namespace ICSharpCode.ILSpy
} }
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile100x), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile100x), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class Decompile100TimesCommand : SimpleCommand sealed class Decompile100TimesCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

4
ILSpy/Commands/DecompileCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
@ -26,7 +26,7 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Commands namespace ICSharpCode.ILSpy.Commands
{ {
[ExportContextMenuEntry(Header = nameof(Resources.Decompile), Order = 10)] [ExportContextMenuEntry(Header = nameof(Resources.Decompile), Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class DecompileCommand : IContextMenuEntry class DecompileCommand : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

5
ILSpy/Commands/DecompileInNewViewCommand.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Windows.Threading; using System.Windows.Threading;
@ -34,12 +34,11 @@ using TomsToolbox.Essentials;
namespace ICSharpCode.ILSpy.Commands namespace ICSharpCode.ILSpy.Commands
{ {
[ExportContextMenuEntry(Header = nameof(Resources.DecompileToNewPanel), InputGestureText = "MMB", Icon = "images/Search", Category = nameof(Resources.Analyze), Order = 90)] [ExportContextMenuEntry(Header = nameof(Resources.DecompileToNewPanel), InputGestureText = "MMB", Icon = "images/Search", Category = nameof(Resources.Analyze), Order = 90)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class DecompileInNewViewCommand : IContextMenuEntry internal sealed class DecompileInNewViewCommand : IContextMenuEntry
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public DecompileInNewViewCommand(AssemblyTreeModel assemblyTreeModel) public DecompileInNewViewCommand(AssemblyTreeModel assemblyTreeModel)
{ {
this.assemblyTreeModel = assemblyTreeModel; this.assemblyTreeModel = assemblyTreeModel;

4
ILSpy/Commands/DisassembleAllCommand.cs

@ -20,7 +20,7 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -30,7 +30,7 @@ using ICSharpCode.ILSpy.TextView;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDisassemble), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDisassemble), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class DisassembleAllCommand : SimpleCommand sealed class DisassembleAllCommand : SimpleCommand
{ {
public override bool CanExecute(object parameter) public override bool CanExecute(object parameter)

4
ILSpy/Commands/ExitCommand.cs

@ -15,14 +15,14 @@
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.E_xit), MenuOrder = 99999, MenuCategory = nameof(Resources.Exit))] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.E_xit), MenuOrder = 99999, MenuCategory = nameof(Resources.Exit))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ExitCommand : SimpleCommand sealed class ExitCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

2
ILSpy/Commands/ExportCommandAttribute.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Input; using System.Windows.Input;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy

4
ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -35,7 +35,7 @@ using Microsoft.Win32;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportContextMenuEntry(Header = nameof(Resources.ExtractPackageEntry), Category = nameof(Resources.Save), Icon = "Images/Save")] [ExportContextMenuEntry(Header = nameof(Resources.ExtractPackageEntry), Category = nameof(Resources.Save), Icon = "Images/Save")]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ExtractPackageEntryContextMenuEntry : IContextMenuEntry sealed class ExtractPackageEntryContextMenuEntry : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)

6
ILSpy/Commands/GeneratePdbContextMenuEntry.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -40,7 +40,7 @@ using Microsoft.Win32;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportContextMenuEntry(Header = nameof(Resources.GeneratePortable))] [ExportContextMenuEntry(Header = nameof(Resources.GeneratePortable))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class GeneratePdbContextMenuEntry : IContextMenuEntry class GeneratePdbContextMenuEntry : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)
@ -107,7 +107,7 @@ namespace ICSharpCode.ILSpy
} }
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.GeneratePortable), MenuCategory = nameof(Resources.Save))] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.GeneratePortable), MenuCategory = nameof(Resources.Save))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class GeneratePdbMainMenuEntry : SimpleCommand class GeneratePdbMainMenuEntry : SimpleCommand
{ {
public override bool CanExecute(object parameter) public override bool CanExecute(object parameter)

4
ILSpy/Commands/ManageAssemblyListsCommand.cs

@ -17,14 +17,14 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ManageAssembly_Lists), MenuIcon = "Images/AssemblyList", MenuCategory = nameof(Resources.Open), MenuOrder = 1.7)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ManageAssembly_Lists), MenuIcon = "Images/AssemblyList", MenuCategory = nameof(Resources.Open), MenuOrder = 1.7)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ManageAssemblyListsCommand : SimpleCommand sealed class ManageAssemblyListsCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

5
ILSpy/Commands/OpenCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
@ -28,12 +28,11 @@ namespace ICSharpCode.ILSpy
{ {
[ExportToolbarCommand(ToolTip = nameof(Resources.Open), ToolbarIcon = "Images/Open", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 0)] [ExportToolbarCommand(ToolTip = nameof(Resources.Open), ToolbarIcon = "Images/Open", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 0)]
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._Open), MenuIcon = "Images/Open", MenuCategory = nameof(Resources.Open), MenuOrder = 0)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._Open), MenuIcon = "Images/Open", MenuCategory = nameof(Resources.Open), MenuOrder = 0)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class OpenCommand : CommandWrapper sealed class OpenCommand : CommandWrapper
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public OpenCommand(AssemblyTreeModel assemblyTreeModel) public OpenCommand(AssemblyTreeModel assemblyTreeModel)
: base(ApplicationCommands.Open) : base(ApplicationCommands.Open)
{ {

5
ILSpy/Commands/OpenFromGacCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.AppEnv; using ICSharpCode.ILSpy.AppEnv;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
@ -25,12 +25,11 @@ using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.OpenFrom_GAC), MenuIcon = "Images/AssemblyListGAC", MenuCategory = nameof(Resources.Open), MenuOrder = 1)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.OpenFrom_GAC), MenuIcon = "Images/AssemblyListGAC", MenuCategory = nameof(Resources.Open), MenuOrder = 1)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class OpenFromGacCommand : SimpleCommand sealed class OpenFromGacCommand : SimpleCommand
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public OpenFromGacCommand(AssemblyTreeModel assemblyTreeModel) public OpenFromGacCommand(AssemblyTreeModel assemblyTreeModel)
{ {
this.assemblyTreeModel = assemblyTreeModel; this.assemblyTreeModel = assemblyTreeModel;

6
ILSpy/Commands/Pdb2XmlCommand.cs

@ -19,7 +19,7 @@
#if DEBUG #if DEBUG
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -35,7 +35,7 @@ using Microsoft.DiaSymReader.Tools;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDumpPDBAsXML), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDumpPDBAsXML), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class Pdb2XmlCommand : SimpleCommand sealed class Pdb2XmlCommand : SimpleCommand
{ {
public override bool CanExecute(object parameter) public override bool CanExecute(object parameter)
@ -72,7 +72,7 @@ namespace ICSharpCode.ILSpy
} }
[ExportContextMenuEntry(Header = nameof(Resources.DEBUGDumpPDBAsXML))] [ExportContextMenuEntry(Header = nameof(Resources.DEBUGDumpPDBAsXML))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class Pdb2XmlCommandContextMenuEntry : IContextMenuEntry class Pdb2XmlCommandContextMenuEntry : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)

5
ILSpy/Commands/RefreshCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Input; using System.Windows.Input;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
@ -26,12 +26,11 @@ namespace ICSharpCode.ILSpy
{ {
[ExportToolbarCommand(ToolTip = nameof(Resources.RefreshCommand_ReloadAssemblies), ToolbarIcon = "Images/Refresh", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 2)] [ExportToolbarCommand(ToolTip = nameof(Resources.RefreshCommand_ReloadAssemblies), ToolbarIcon = "Images/Refresh", ToolbarCategory = nameof(Resources.Open), ToolbarOrder = 2)]
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._Reload), MenuIcon = "Images/Refresh", MenuCategory = nameof(Resources.Open), MenuOrder = 2)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._Reload), MenuIcon = "Images/Refresh", MenuCategory = nameof(Resources.Open), MenuOrder = 2)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class RefreshCommand : CommandWrapper sealed class RefreshCommand : CommandWrapper
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public RefreshCommand(AssemblyTreeModel assemblyTreeModel) public RefreshCommand(AssemblyTreeModel assemblyTreeModel)
: base(NavigationCommands.Refresh) : base(NavigationCommands.Refresh)
{ {

8
ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
@ -25,12 +25,11 @@ using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._RemoveAssembliesWithLoadErrors), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._RemoveAssembliesWithLoadErrors), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class RemoveAssembliesWithLoadErrors : SimpleCommand class RemoveAssembliesWithLoadErrors : SimpleCommand
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public RemoveAssembliesWithLoadErrors(AssemblyTreeModel assemblyTreeModel) public RemoveAssembliesWithLoadErrors(AssemblyTreeModel assemblyTreeModel)
{ {
this.assemblyTreeModel = assemblyTreeModel; this.assemblyTreeModel = assemblyTreeModel;
@ -55,12 +54,11 @@ namespace ICSharpCode.ILSpy
} }
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ClearAssemblyList), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ClearAssemblyList), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class ClearAssemblyList : SimpleCommand class ClearAssemblyList : SimpleCommand
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public ClearAssemblyList(AssemblyTreeModel assemblyTreeModel) public ClearAssemblyList(AssemblyTreeModel assemblyTreeModel)
{ {
this.assemblyTreeModel = assemblyTreeModel; this.assemblyTreeModel = assemblyTreeModel;

4
ILSpy/Commands/SaveCodeContextMenuEntry.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
@ -34,7 +34,7 @@ using Microsoft.Win32;
namespace ICSharpCode.ILSpy.TextView namespace ICSharpCode.ILSpy.TextView
{ {
[ExportContextMenuEntry(Header = nameof(Resources._SaveCode), Category = nameof(Resources.Save), Icon = "Images/Save")] [ExportContextMenuEntry(Header = nameof(Resources._SaveCode), Category = nameof(Resources.Save), Icon = "Images/Save")]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class SaveCodeContextMenuEntry : IContextMenuEntry sealed class SaveCodeContextMenuEntry : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)

5
ILSpy/Commands/SaveCommand.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Windows.Input; using System.Windows.Input;
@ -27,12 +27,11 @@ using ICSharpCode.ILSpy.TextView;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._SaveCode), MenuIcon = "Images/Save", MenuCategory = nameof(Resources.Save), MenuOrder = 0)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._SaveCode), MenuIcon = "Images/Save", MenuCategory = nameof(Resources.Save), MenuOrder = 0)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class SaveCommand : CommandWrapper sealed class SaveCommand : CommandWrapper
{ {
private AssemblyTreeModel assemblyTreeModel; private AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public SaveCommand(AssemblyTreeModel assemblyTreeModel) public SaveCommand(AssemblyTreeModel assemblyTreeModel)
: base(ApplicationCommands.Save) : base(ApplicationCommands.Save)
{ {

5
ILSpy/Commands/ScopeSearchToAssembly.cs

@ -18,7 +18,7 @@
#nullable enable #nullable enable
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.AppEnv; using ICSharpCode.ILSpy.AppEnv;
@ -29,12 +29,11 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportContextMenuEntry(Header = nameof(Resources.ScopeSearchToThisAssembly), Category = nameof(Resources.Analyze), Order = 9999)] [ExportContextMenuEntry(Header = nameof(Resources.ScopeSearchToThisAssembly), Category = nameof(Resources.Analyze), Order = 9999)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class ScopeSearchToAssembly : IContextMenuEntry public class ScopeSearchToAssembly : IContextMenuEntry
{ {
private readonly SearchPaneModel searchPane; private readonly SearchPaneModel searchPane;
[ImportingConstructor]
public ScopeSearchToAssembly(SearchPaneModel searchPane) public ScopeSearchToAssembly(SearchPaneModel searchPane)
{ {
this.searchPane = searchPane; this.searchPane = searchPane;

5
ILSpy/Commands/ScopeSearchToNamespace.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.AppEnv; using ICSharpCode.ILSpy.AppEnv;
@ -27,12 +27,11 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportContextMenuEntry(Header = nameof(Resources.ScopeSearchToThisNamespace), Category = nameof(Resources.Analyze), Order = 9999)] [ExportContextMenuEntry(Header = nameof(Resources.ScopeSearchToThisNamespace), Category = nameof(Resources.Analyze), Order = 9999)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class ScopeSearchToNamespace : IContextMenuEntry public class ScopeSearchToNamespace : IContextMenuEntry
{ {
private readonly SearchPaneModel searchPane; private readonly SearchPaneModel searchPane;
[ImportingConstructor]
public ScopeSearchToNamespace(SearchPaneModel searchPane) public ScopeSearchToNamespace(SearchPaneModel searchPane)
{ {
this.searchPane = searchPane; this.searchPane = searchPane;

4
ILSpy/Commands/SearchMsdnContextMenuEntry.cs

@ -23,12 +23,12 @@ using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TreeNodes; using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
[ExportContextMenuEntry(Header = nameof(Resources.SearchMSDN), Icon = "images/SearchMsdn", Order = 9999)] [ExportContextMenuEntry(Header = nameof(Resources.SearchMSDN), Icon = "images/SearchMsdn", Order = 9999)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class SearchMsdnContextMenuEntry : IContextMenuEntry internal sealed class SearchMsdnContextMenuEntry : IContextMenuEntry
{ {
private static string msdnAddress = "https://docs.microsoft.com/dotnet/api/{0}"; private static string msdnAddress = "https://docs.microsoft.com/dotnet/api/{0}";

4
ILSpy/Commands/SelectPdbContextMenuEntry.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -28,7 +28,7 @@ using Microsoft.Win32;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[ExportContextMenuEntry(Header = nameof(Resources.SelectPDB))] [ExportContextMenuEntry(Header = nameof(Resources.SelectPDB))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class SelectPdbContextMenuEntry : IContextMenuEntry class SelectPdbContextMenuEntry : IContextMenuEntry
{ {
public async void Execute(TextViewContext context) public async void Execute(TextViewContext context)

4
ILSpy/Commands/ShowCFGContextMenuEntry.cs

@ -1,6 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Windows; using System.Windows;
using ICSharpCode.Decompiler.FlowAnalysis; using ICSharpCode.Decompiler.FlowAnalysis;
@ -11,7 +11,7 @@ namespace ICSharpCode.ILSpy.Commands
{ {
#if DEBUG #if DEBUG
[ExportContextMenuEntry(Header = "DEBUG -- Show CFG")] [ExportContextMenuEntry(Header = "DEBUG -- Show CFG")]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal class ShowCFGContextMenuEntry : IContextMenuEntry internal class ShowCFGContextMenuEntry : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)

6
ILSpy/Commands/SortAssemblyListCommand.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpyX; using ICSharpCode.ILSpyX;
@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy
{ {
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources.SortAssembly_listName), MenuIcon = "Images/Sort", MenuCategory = nameof(Resources.View))] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources.SortAssembly_listName), MenuIcon = "Images/Sort", MenuCategory = nameof(Resources.View))]
[ExportToolbarCommand(ToolTip = nameof(Resources.SortAssemblyListName), ToolbarIcon = "Images/Sort", ToolbarCategory = nameof(Resources.View))] [ExportToolbarCommand(ToolTip = nameof(Resources.SortAssemblyListName), ToolbarIcon = "Images/Sort", ToolbarCategory = nameof(Resources.View))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class SortAssemblyListCommand : SimpleCommand sealed class SortAssemblyListCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)
@ -39,7 +39,7 @@ namespace ICSharpCode.ILSpy
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources._CollapseTreeNodes), MenuIcon = "Images/CollapseAll", MenuCategory = nameof(Resources.View))] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources._CollapseTreeNodes), MenuIcon = "Images/CollapseAll", MenuCategory = nameof(Resources.View))]
[ExportToolbarCommand(ToolTip = nameof(Resources.CollapseTreeNodes), ToolbarIcon = "Images/CollapseAll", ToolbarCategory = nameof(Resources.View))] [ExportToolbarCommand(ToolTip = nameof(Resources.CollapseTreeNodes), ToolbarIcon = "Images/CollapseAll", ToolbarCategory = nameof(Resources.View))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class CollapseAllCommand : SimpleCommand sealed class CollapseAllCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

2
ILSpy/ContextMenuEntry.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;

6
ILSpy/Docking/CloseAllDocumentsCommand.cs

@ -1,11 +1,11 @@
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy.Docking namespace ICSharpCode.ILSpy.Docking
{ {
[ExportMainMenuCommand(Header = nameof(Resources.Window_CloseAllDocuments), ParentMenuID = nameof(Resources._Window))] [ExportMainMenuCommand(Header = nameof(Resources.Window_CloseAllDocuments), ParentMenuID = nameof(Resources._Window))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class CloseAllDocumentsCommand : SimpleCommand class CloseAllDocumentsCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)
@ -15,7 +15,7 @@ namespace ICSharpCode.ILSpy.Docking
} }
[ExportMainMenuCommand(Header = nameof(Resources.Window_ResetLayout), ParentMenuID = nameof(Resources._Window))] [ExportMainMenuCommand(Header = nameof(Resources.Window_ResetLayout), ParentMenuID = nameof(Resources._Window))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class ResetLayoutCommand : SimpleCommand class ResetLayoutCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

103
ILSpy/ExportProviderAdapter.cs

@ -1,103 +0,0 @@
// Copyright (c) 2024 Tom Englert for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.VisualStudio.Composition;
using TomsToolbox.Composition;
using TomsToolbox.Essentials;
namespace ICSharpCode.ILSpy;
#nullable enable
/// <summary>
/// Adapter for Microsoft.VisualStudio.Composition.<see cref="ExportProvider"/> to <see cref="IExportProvider"/>.
/// </summary>
public sealed class ExportProviderAdapter : IExportProvider
{
private static readonly Type DefaultMetadataType = typeof(Dictionary<string, object>);
private readonly ExportProvider _exportProvider;
/// <summary>
/// Initializes a new instance of the <see cref="ExportProviderAdapter"/> class.
/// </summary>
/// <param name="exportProvider">The export provider.</param>
public ExportProviderAdapter(ExportProvider exportProvider)
{
_exportProvider = exportProvider;
}
event EventHandler<EventArgs>? IExportProvider.ExportsChanged { add { } remove { } }
T IExportProvider.GetExportedValue<T>(string? contractName) where T : class
{
return _exportProvider.GetExportedValue<T>(contractName) ?? throw new InvalidOperationException($"No export found for type {typeof(T).FullName} with contract '{contractName}'");
}
T? IExportProvider.GetExportedValueOrDefault<T>(string? contractName) where T : class
{
return _exportProvider.GetExportedValues<T>(contractName).SingleOrDefault();
}
bool IExportProvider.TryGetExportedValue<T>(string? contractName, [NotNullWhen(true)] out T? value) where T : class
{
value = _exportProvider.GetExportedValues<T>(contractName).SingleOrDefault();
return !Equals(value, default(T));
}
IEnumerable<T> IExportProvider.GetExportedValues<T>(string? contractName) where T : class
{
return _exportProvider.GetExportedValues<T>(contractName);
}
IEnumerable<object> IExportProvider.GetExportedValues(Type contractType, string? contractName)
{
return _exportProvider
.GetExports(contractType, DefaultMetadataType, contractName)
.Select(item => item.Value)
.ExceptNullItems();
}
IEnumerable<IExport<object>> IExportProvider.GetExports(Type contractType, string? contractName)
{
return _exportProvider
.GetExports(contractType, DefaultMetadataType, contractName)
.Select(item => new ExportAdapter<object>(() => item.Value, new MetadataAdapter((IDictionary<string, object?>)item.Metadata)));
}
IEnumerable<IExport<T>> IExportProvider.GetExports<T>(string? contractName) where T : class
{
return _exportProvider
.GetExports(typeof(T), DefaultMetadataType, contractName)
.Select(item => new ExportAdapter<T>(() => (T?)item.Value, new MetadataAdapter((IDictionary<string, object?>)item.Metadata)));
}
IEnumerable<IExport<T, TMetadataView>> IExportProvider.GetExports<T, TMetadataView>(string? contractName) where T : class where TMetadataView : class
{
return _exportProvider
.GetExports<T, TMetadataView>(contractName)
.Select(item => new ExportAdapter<T, TMetadataView>(() => item.Value, item.Metadata));
}
}

44
ILSpy/ExtensionMethods.cs

@ -20,6 +20,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@ -166,34 +167,37 @@ namespace ICSharpCode.ILSpy
return color?.R * 0.3 + color?.G * 0.6 + color?.B * 0.1 ?? 0.0; return color?.R * 0.3 + color?.G * 0.6 + color?.B * 0.1 ?? 0.0;
} }
internal static bool FormatExceptions(this IList<App.ExceptionData> exceptions, StringBuilder output) internal static string? FormatExceptions(this IList<App.ExceptionData> exceptions)
{ {
if (exceptions.Count == 0) if (exceptions.Count == 0)
return false; return null;
bool first = true;
foreach (var item in exceptions) string delimiter = $"-------------------------------------------------{Environment.NewLine}";
{
if (first) return string.Join(delimiter, exceptions.Select(FormatException));
first = false; }
else
output.AppendLine("-------------------------------------------------"); private static string FormatException(App.ExceptionData item)
{
var output = new StringBuilder();
if (!item.PluginName.IsNullOrEmpty())
output.AppendLine("Error(s) loading plugin: " + item.PluginName); output.AppendLine("Error(s) loading plugin: " + item.PluginName);
if (item.Exception is System.Reflection.ReflectionTypeLoadException exception)
{ if (item.Exception is System.Reflection.ReflectionTypeLoadException exception)
foreach (var ex in exception.LoaderExceptions.ExceptNullItems()) {
{ foreach (var ex in exception.LoaderExceptions.ExceptNullItems())
output.AppendLine(ex.ToString());
output.AppendLine();
}
}
else
{ {
output.AppendLine(item.Exception.ToString()); output.AppendLine(ex.ToString());
output.AppendLine();
} }
} }
else
{
output.AppendLine(item.Exception.ToString());
}
return true; return output.ToString();
} }
public static IDisposable PreserveFocus(this IInputElement? inputElement, bool preserve = true) public static IDisposable PreserveFocus(this IInputElement? inputElement, bool preserve = true)

6
ILSpy/ILSpy.csproj

@ -45,12 +45,12 @@
<PackageReference Include="AvalonEdit" /> <PackageReference Include="AvalonEdit" />
<PackageReference Include="Dirkster.AvalonDock.Themes.VS2013" /> <PackageReference Include="Dirkster.AvalonDock.Themes.VS2013" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" /> <PackageReference Include="McMaster.Extensions.CommandLineUtils" />
<PackageReference Include="Microsoft.VisualStudio.Composition" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="DataGridExtensions" /> <PackageReference Include="DataGridExtensions" />
<PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" /> <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" />
<PackageReference Include="NaturalSort.Extension" /> <PackageReference Include="NaturalSort.Extension" />
<PackageReference Include="TomsToolbox.Wpf.Composition" /> <PackageReference Include="TomsToolbox.Composition.MicrosoftExtensions" />
<PackageReference Include="TomsToolbox.Wpf.Composition.Mef" /> <PackageReference Include="TomsToolbox.Wpf.Composition.AttributedModel" />
<PackageReference Include="TomsToolbox.Wpf.Styles" /> <PackageReference Include="TomsToolbox.Wpf.Styles" />
</ItemGroup> </ItemGroup>

4
ILSpy/Languages/CSharpILMixedLanguage.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -42,7 +42,7 @@ namespace ICSharpCode.ILSpy
using SequencePoint = ICSharpCode.Decompiler.DebugInfo.SequencePoint; using SequencePoint = ICSharpCode.Decompiler.DebugInfo.SequencePoint;
[Export(typeof(Language))] [Export(typeof(Language))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class CSharpILMixedLanguage : ILLanguage class CSharpILMixedLanguage : ILLanguage
{ {
public override string Name => "IL with C#"; public override string Name => "IL with C#";

7
ILSpy/Languages/CSharpLanguage.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -52,7 +52,7 @@ namespace ICSharpCode.ILSpy
/// please directly use the CSharpDecompiler class. /// please directly use the CSharpDecompiler class.
/// </summary> /// </summary>
[Export(typeof(Language))] [Export(typeof(Language))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class CSharpLanguage : Language public class CSharpLanguage : Language
{ {
readonly IReadOnlyCollection<IResourceFileHandler> resourceFileHandlers; readonly IReadOnlyCollection<IResourceFileHandler> resourceFileHandlers;
@ -61,8 +61,7 @@ namespace ICSharpCode.ILSpy
bool showAllMembers = false; bool showAllMembers = false;
int transformCount = int.MaxValue; int transformCount = int.MaxValue;
[ImportingConstructor] public CSharpLanguage(IEnumerable<IResourceFileHandler> resourceFileHandlers)
public CSharpLanguage([ImportMany] IEnumerable<IResourceFileHandler> resourceFileHandlers)
{ {
this.resourceFileHandlers = resourceFileHandlers.ToArray(); this.resourceFileHandlers = resourceFileHandlers.ToArray();
} }

4
ILSpy/Languages/ILLanguage.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -43,7 +43,7 @@ namespace ICSharpCode.ILSpy
/// flat IL (detectControlStructure=false) and structured IL (detectControlStructure=true). /// flat IL (detectControlStructure=false) and structured IL (detectControlStructure=true).
/// </remarks> /// </remarks>
[Export(typeof(Language))] [Export(typeof(Language))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class ILLanguage : Language public class ILLanguage : Language
{ {
protected bool detectControlStructure = true; protected bool detectControlStructure = true;

6
ILSpy/Metadata/GoToTokenCommand.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Reflection.Metadata.Ecma335; using System.Reflection.Metadata.Ecma335;
@ -33,7 +33,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.Commands namespace ICSharpCode.ILSpy.Commands
{ {
[ExportContextMenuEntry(Header = nameof(Resources.GoToToken), Order = 10)] [ExportContextMenuEntry(Header = nameof(Resources.GoToToken), Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class GoToTokenCommand : IContextMenuEntry class GoToTokenCommand : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)
@ -71,7 +71,7 @@ namespace ICSharpCode.ILSpy.Commands
} }
[ExportContextMenuEntry(Header = nameof(Resources.Copy), Order = 10)] [ExportContextMenuEntry(Header = nameof(Resources.Copy), Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class CopyCommand : IContextMenuEntry class CopyCommand : IContextMenuEntry
{ {
public void Execute(TextViewContext context) public void Execute(TextViewContext context)

4
ILSpy/Metadata/MetadataProtocolHandler.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection.Metadata; using System.Reflection.Metadata;
@ -26,7 +26,7 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace ICSharpCode.ILSpy.Metadata namespace ICSharpCode.ILSpy.Metadata
{ {
[Export(typeof(IProtocolHandler))] [Export(typeof(IProtocolHandler))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
class MetadataProtocolHandler : IProtocolHandler class MetadataProtocolHandler : IProtocolHandler
{ {
public ILSpyTreeNode Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage) public ILSpyTreeNode Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage)

6
ILSpy/Options/DecompilerSettingsPanel.xaml.cs

@ -16,12 +16,12 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.ILSpyX.Settings; using ICSharpCode.ILSpyX.Settings;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {
@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpy.Options
/// Interaction logic for DecompilerSettingsPanel.xaml /// Interaction logic for DecompilerSettingsPanel.xaml
/// </summary> /// </summary>
[DataTemplate(typeof(DecompilerSettingsViewModel))] [DataTemplate(typeof(DecompilerSettingsViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
internal partial class DecompilerSettingsPanel internal partial class DecompilerSettingsPanel
{ {
public DecompilerSettingsPanel() public DecompilerSettingsPanel()

4
ILSpy/Options/DecompilerSettingsViewModel.cs

@ -18,7 +18,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
@ -30,7 +30,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {
[ExportOptionPage(Order = 10)] [ExportOptionPage(Order = 10)]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public sealed class DecompilerSettingsViewModel : ObservableObjectBase, IOptionPage public sealed class DecompilerSettingsViewModel : ObservableObjectBase, IOptionPage
{ {
private static readonly PropertyInfo[] propertyInfos = typeof(Decompiler.DecompilerSettings).GetProperties() private static readonly PropertyInfo[] propertyInfos = typeof(Decompiler.DecompilerSettings).GetProperties()

6
ILSpy/Options/DisplaySettingsPanel.xaml.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -29,7 +29,7 @@ using System.Xml.Linq;
using ICSharpCode.ILSpyX.Settings; using ICSharpCode.ILSpyX.Settings;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
using TomsToolbox.Wpf.Converters; using TomsToolbox.Wpf.Converters;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.Options
/// <summary> /// <summary>
/// Interaction logic for DisplaySettingsPanel.xaml /// Interaction logic for DisplaySettingsPanel.xaml
/// </summary> /// </summary>
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
[DataTemplate(typeof(DisplaySettingsViewModel))] [DataTemplate(typeof(DisplaySettingsViewModel))]
public partial class DisplaySettingsPanel public partial class DisplaySettingsPanel
{ {

4
ILSpy/Options/DisplaySettingsViewModel.cs

@ -2,7 +2,7 @@
using System.Windows.Media; using System.Windows.Media;
using System.Xml.Linq; using System.Xml.Linq;
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
@ -13,7 +13,7 @@ using ICSharpCode.ILSpy.Themes;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {
[ExportOptionPage(Order = 20)] [ExportOptionPage(Order = 20)]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public class DisplaySettingsViewModel : ObservableObject, IOptionPage public class DisplaySettingsViewModel : ObservableObject, IOptionPage
{ {
private DisplaySettings settings = new(); private DisplaySettings settings = new();

6
ILSpy/Options/MiscSettingsPanel.xaml.cs

@ -16,11 +16,11 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Controls; using System.Windows.Controls;
using System.Xml.Linq; using System.Xml.Linq;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {
@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy.Options
/// Interaction logic for MiscSettingsPanel.xaml /// Interaction logic for MiscSettingsPanel.xaml
/// </summary> /// </summary>
[DataTemplate(typeof(MiscSettingsViewModel))] [DataTemplate(typeof(MiscSettingsViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public partial class MiscSettingsPanel public partial class MiscSettingsPanel
{ {
public MiscSettingsPanel() public MiscSettingsPanel()

4
ILSpy/Options/MiscSettingsViewModel.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows; using System.Windows;
@ -33,7 +33,7 @@ using TomsToolbox.Wpf;
namespace ICSharpCode.ILSpy.Options namespace ICSharpCode.ILSpy.Options
{ {
[ExportOptionPage(Order = 30)] [ExportOptionPage(Order = 30)]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public class MiscSettingsViewModel : ObservableObject, IOptionPage public class MiscSettingsViewModel : ObservableObject, IOptionPage
{ {
private MiscSettings settings; private MiscSettings settings;

5
ILSpy/Options/OptionsDialog.xaml.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.AssemblyTree;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
@ -58,12 +58,11 @@ namespace ICSharpCode.ILSpy.Options
} }
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources._Options), MenuCategory = nameof(Resources.Options), MenuOrder = 999)] [ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources._Options), MenuCategory = nameof(Resources.Options), MenuOrder = 999)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ShowOptionsCommand : SimpleCommand sealed class ShowOptionsCommand : SimpleCommand
{ {
private readonly AssemblyTreeModel assemblyTreeModel; private readonly AssemblyTreeModel assemblyTreeModel;
[ImportingConstructor]
public ShowOptionsCommand(AssemblyTreeModel assemblyTreeModel) public ShowOptionsCommand(AssemblyTreeModel assemblyTreeModel)
{ {
this.assemblyTreeModel = assemblyTreeModel; this.assemblyTreeModel = assemblyTreeModel;

8
ILSpy/Search/SearchPane.xaml.cs

@ -21,7 +21,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
@ -41,7 +41,7 @@ using ICSharpCode.ILSpyX.Search;
using TomsToolbox.Essentials; using TomsToolbox.Essentials;
using TomsToolbox.Wpf; using TomsToolbox.Wpf;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy.Search namespace ICSharpCode.ILSpy.Search
{ {
@ -49,7 +49,7 @@ namespace ICSharpCode.ILSpy.Search
/// Search pane /// Search pane
/// </summary> /// </summary>
[DataTemplate(typeof(SearchPaneModel))] [DataTemplate(typeof(SearchPaneModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public partial class SearchPane public partial class SearchPane
{ {
const int MAX_RESULTS = 1000; const int MAX_RESULTS = 1000;
@ -535,7 +535,7 @@ namespace ICSharpCode.ILSpy.Search
} }
[ExportToolbarCommand(ToolTip = nameof(Properties.Resources.SearchCtrlShiftFOrCtrlE), ToolbarIcon = "Images/Search", ToolbarCategory = nameof(Properties.Resources.View), ToolbarOrder = 100)] [ExportToolbarCommand(ToolTip = nameof(Properties.Resources.SearchCtrlShiftFOrCtrlE), ToolbarIcon = "Images/Search", ToolbarCategory = nameof(Properties.Resources.View), ToolbarOrder = 100)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ShowSearchCommand : CommandWrapper sealed class ShowSearchCommand : CommandWrapper
{ {
public ShowSearchCommand() public ShowSearchCommand()

4
ILSpy/Search/SearchPaneModel.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpy.Search
} }
[ExportToolPane] [ExportToolPane]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
[Export] [Export]
public class SearchPaneModel : ToolPaneModel public class SearchPaneModel : ToolPaneModel
{ {

6
ILSpy/TextView/EditorCommands.cs

@ -16,14 +16,14 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy.Properties; using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy.TextView namespace ICSharpCode.ILSpy.TextView
{ {
[ExportContextMenuEntry(Header = nameof(Resources.Copy), Category = nameof(Resources.Editor))] [ExportContextMenuEntry(Header = nameof(Resources.Copy), Category = nameof(Resources.Editor))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class CopyContextMenuEntry : IContextMenuEntry sealed class CopyContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -43,7 +43,7 @@ namespace ICSharpCode.ILSpy.TextView
} }
[ExportContextMenuEntry(Header = nameof(Resources.Select), Category = nameof(Resources.Editor))] [ExportContextMenuEntry(Header = nameof(Resources.Select), Category = nameof(Resources.Editor))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class SelectAllContextMenuEntry : IContextMenuEntry sealed class SelectAllContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

6
ILSpy/TextView/FoldingCommands.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using ICSharpCode.AvalonEdit; using ICSharpCode.AvalonEdit;
@ -26,7 +26,7 @@ using ICSharpCode.ILSpy.Properties;
namespace ICSharpCode.ILSpy.TextView namespace ICSharpCode.ILSpy.TextView
{ {
[ExportContextMenuEntryAttribute(Header = nameof(Resources.ToggleFolding), Category = nameof(Resources.Folding))] [ExportContextMenuEntryAttribute(Header = nameof(Resources.ToggleFolding), Category = nameof(Resources.Folding))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class ToggleAllContextMenuEntry : IContextMenuEntry internal sealed class ToggleAllContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -63,7 +63,7 @@ namespace ICSharpCode.ILSpy.TextView
} }
[ExportContextMenuEntryAttribute(Header = nameof(Resources._ToggleFolding), Category = nameof(Resources.Folding))] [ExportContextMenuEntryAttribute(Header = nameof(Resources._ToggleFolding), Category = nameof(Resources.Folding))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
internal sealed class ToggleContextMenuEntry : IContextMenuEntry internal sealed class ToggleContextMenuEntry : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

14
ILSpy/TreeNodes/AssemblyTreeNode.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -580,7 +580,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources._Remove), Icon = "images/Delete")] [ExportContextMenuEntry(Header = nameof(Resources._Remove), Icon = "images/Delete")]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class RemoveAssembly : IContextMenuEntry sealed class RemoveAssembly : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -607,7 +607,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources._Reload), Icon = "images/Refresh")] [ExportContextMenuEntry(Header = nameof(Resources._Reload), Icon = "images/Refresh")]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ReloadAssembly : IContextMenuEntry sealed class ReloadAssembly : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -642,7 +642,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources._LoadDependencies), Category = nameof(Resources.Dependencies))] [ExportContextMenuEntry(Header = nameof(Resources._LoadDependencies), Category = nameof(Resources.Dependencies))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class LoadDependencies : IContextMenuEntry sealed class LoadDependencies : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -682,7 +682,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources._AddMainList), Category = nameof(Resources.Dependencies))] [ExportContextMenuEntry(Header = nameof(Resources._AddMainList), Category = nameof(Resources.Dependencies))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class AddToMainList : IContextMenuEntry sealed class AddToMainList : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -717,7 +717,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources._OpenContainingFolder), Category = nameof(Resources.Shell))] [ExportContextMenuEntry(Header = nameof(Resources._OpenContainingFolder), Category = nameof(Resources.Shell))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class OpenContainingFolder : IContextMenuEntry sealed class OpenContainingFolder : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)
@ -770,7 +770,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources._OpenCommandLineHere), Category = nameof(Resources.Shell))] [ExportContextMenuEntry(Header = nameof(Resources._OpenCommandLineHere), Category = nameof(Resources.Shell))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class OpenCmdHere : IContextMenuEntry sealed class OpenCmdHere : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

4
ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -31,7 +31,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes namespace ICSharpCode.ILSpy.TreeNodes
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class CursorResourceNodeFactory : IResourceNodeFactory sealed class CursorResourceNodeFactory : IResourceNodeFactory
{ {
static readonly string[] imageFileExtensions = { ".cur" }; static readonly string[] imageFileExtensions = { ".cur" };

4
ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -31,7 +31,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes namespace ICSharpCode.ILSpy.TreeNodes
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class IconResourceNodeFactory : IResourceNodeFactory sealed class IconResourceNodeFactory : IResourceNodeFactory
{ {
public ITreeNode CreateNode(Resource resource) public ITreeNode CreateNode(Resource resource)

4
ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs

@ -16,7 +16,7 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
@ -28,7 +28,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes namespace ICSharpCode.ILSpy.TreeNodes
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ImageListResourceEntryNodeFactory : IResourceNodeFactory sealed class ImageListResourceEntryNodeFactory : IResourceNodeFactory
{ {
public ITreeNode CreateNode(Resource resource) public ITreeNode CreateNode(Resource resource)

4
ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
@ -31,7 +31,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.TreeNodes namespace ICSharpCode.ILSpy.TreeNodes
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ImageResourceNodeFactory : IResourceNodeFactory sealed class ImageResourceNodeFactory : IResourceNodeFactory
{ {
static readonly string[] imageFileExtensions = { ".png", ".gif", ".bmp", ".jpg" }; static readonly string[] imageFileExtensions = { ".png", ".gif", ".bmp", ".jpg" };

4
ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs

@ -19,7 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -38,7 +38,7 @@ using Microsoft.Win32;
namespace ICSharpCode.ILSpy.TreeNodes namespace ICSharpCode.ILSpy.TreeNodes
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class ResourcesFileTreeNodeFactory : IResourceNodeFactory sealed class ResourcesFileTreeNodeFactory : IResourceNodeFactory
{ {
public ITreeNode CreateNode(Resource resource) public ITreeNode CreateNode(Resource resource)

4
ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -31,7 +31,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Xaml namespace ICSharpCode.ILSpy.Xaml
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class XamlResourceNodeFactory : IResourceNodeFactory sealed class XamlResourceNodeFactory : IResourceNodeFactory
{ {
public ITreeNode CreateNode(Resource resource) public ITreeNode CreateNode(Resource resource)

4
ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs

@ -17,7 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.ComponentModel.Composition; using System.Composition;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -31,7 +31,7 @@ using ICSharpCode.ILSpyX.Abstractions;
namespace ICSharpCode.ILSpy.Xaml namespace ICSharpCode.ILSpy.Xaml
{ {
[Export(typeof(IResourceNodeFactory))] [Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class XmlResourceNodeFactory : IResourceNodeFactory sealed class XmlResourceNodeFactory : IResourceNodeFactory
{ {
private readonly static string[] xmlFileExtensions = { ".xml", ".xsd", ".xslt" }; private readonly static string[] xmlFileExtensions = { ".xml", ".xsd", ".xslt" };

4
ILSpy/TreeNodes/ThreadingSupport.cs

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.Composition; using System.Composition;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -172,7 +172,7 @@ namespace ICSharpCode.ILSpy.TreeNodes
} }
[ExportContextMenuEntry(Header = nameof(Resources.CopyErrorMessage))] [ExportContextMenuEntry(Header = nameof(Resources.CopyErrorMessage))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
sealed class CopyErrorMessageContextMenu : IContextMenuEntry sealed class CopyErrorMessageContextMenu : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

4
ILSpy/ViewModels/DebugStepsPaneModel.cs

@ -16,14 +16,14 @@
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System.ComponentModel.Composition; using System.Composition;
using System.Windows; using System.Windows;
namespace ICSharpCode.ILSpy.ViewModels namespace ICSharpCode.ILSpy.ViewModels
{ {
#if DEBUG #if DEBUG
[ExportToolPane] [ExportToolPane]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
#endif #endif
public class DebugStepsPaneModel : ToolPaneModel public class DebugStepsPaneModel : ToolPaneModel
{ {

6
ILSpy/Views/DebugSteps.xaml.cs

@ -1,6 +1,6 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Composition; using System.Composition;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
@ -10,12 +10,12 @@ using ICSharpCode.Decompiler.IL.Transforms;
using ICSharpCode.ILSpy.Docking; using ICSharpCode.ILSpy.Docking;
using ICSharpCode.ILSpy.ViewModels; using ICSharpCode.ILSpy.ViewModels;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace ICSharpCode.ILSpy namespace ICSharpCode.ILSpy
{ {
[DataTemplate(typeof(DebugStepsPaneModel))] [DataTemplate(typeof(DebugStepsPaneModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
public partial class DebugSteps : UserControl public partial class DebugSteps : UserControl
{ {
static readonly ILAstWritingOptions writingOptions = new ILAstWritingOptions { static readonly ILAstWritingOptions writingOptions = new ILAstWritingOptions {

4
TestPlugin/AboutPageAddition.cs

@ -1,7 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System.ComponentModel.Composition; using System.Composition;
using System.Windows; using System.Windows;
using System.Windows.Media; using System.Windows.Media;
@ -11,7 +11,7 @@ using ICSharpCode.ILSpy;
namespace TestPlugin namespace TestPlugin
{ {
[Export(typeof(IAboutPageAddition))] [Export(typeof(IAboutPageAddition))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class AboutPageAddition : IAboutPageAddition public class AboutPageAddition : IAboutPageAddition
{ {
public void Write(ISmartTextOutput textOutput) public void Write(ISmartTextOutput textOutput)

4
TestPlugin/ContextMenuCommand.cs

@ -1,7 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System.ComponentModel.Composition; using System.Composition;
using System.Linq; using System.Linq;
using ICSharpCode.ILSpy; using ICSharpCode.ILSpy;
@ -10,7 +10,7 @@ using ICSharpCode.ILSpy.TreeNodes;
namespace TestPlugin namespace TestPlugin
{ {
[ExportContextMenuEntryAttribute(Header = "_Save Assembly")] [ExportContextMenuEntryAttribute(Header = "_Save Assembly")]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class SaveAssembly : IContextMenuEntry public class SaveAssembly : IContextMenuEntry
{ {
public bool IsVisible(TextViewContext context) public bool IsVisible(TextViewContext context)

4
TestPlugin/CustomLanguage.cs

@ -1,7 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System.ComponentModel.Composition; using System.Composition;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Windows.Controls; using System.Windows.Controls;
@ -15,7 +15,7 @@ namespace TestPlugin
/// Adds a new language to the decompiler. /// Adds a new language to the decompiler.
/// </summary> /// </summary>
[Export(typeof(Language))] [Export(typeof(Language))]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class CustomLanguage : Language public class CustomLanguage : Language
{ {
public override string Name { public override string Name {

8
TestPlugin/CustomOptionPage.xaml.cs

@ -1,19 +1,19 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System.ComponentModel.Composition; using System.Composition;
using System.Xml.Linq; using System.Xml.Linq;
using ICSharpCode.ILSpy.Options; using ICSharpCode.ILSpy.Options;
using ICSharpCode.ILSpy.Util; using ICSharpCode.ILSpy.Util;
using TomsToolbox.Wpf; using TomsToolbox.Wpf;
using TomsToolbox.Wpf.Composition.Mef; using TomsToolbox.Wpf.Composition.AttributedModel;
namespace TestPlugin namespace TestPlugin
{ {
[DataTemplate(typeof(CustomOptionsViewModel))] [DataTemplate(typeof(CustomOptionsViewModel))]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
partial class CustomOptionPage partial class CustomOptionPage
{ {
public CustomOptionPage() public CustomOptionPage()
@ -23,7 +23,7 @@ namespace TestPlugin
} }
[ExportOptionPage(Order = 0)] [ExportOptionPage(Order = 0)]
[PartCreationPolicy(CreationPolicy.NonShared)] [NonShared]
class CustomOptionsViewModel : ObservableObject, IOptionPage class CustomOptionsViewModel : ObservableObject, IOptionPage
{ {
private Options options; private Options options;

4
TestPlugin/MainMenuCommand.cs

@ -1,7 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under MIT X11 license (for details please see \doc\license.txt) // This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System.ComponentModel.Composition; using System.Composition;
using ICSharpCode.ILSpy; using ICSharpCode.ILSpy;
@ -18,7 +18,7 @@ namespace TestPlugin
// ToolbarCategory: optional, used for grouping related toolbar items together. A separator is added between different groups. // ToolbarCategory: optional, used for grouping related toolbar items together. A separator is added between different groups.
// ToolbarOrder: controls the order in which the items appear (items are sorted by this value) // ToolbarOrder: controls the order in which the items appear (items are sorted by this value)
[ExportToolbarCommand(ToolTip = "Clears the current assembly list", ToolbarIcon = "Clear.png", ToolbarCategory = "Open", ToolbarOrder = 1.5)] [ExportToolbarCommand(ToolTip = "Clears the current assembly list", ToolbarIcon = "Clear.png", ToolbarCategory = "Open", ToolbarOrder = 1.5)]
[PartCreationPolicy(CreationPolicy.Shared)] [Shared]
public class UnloadAllAssembliesCommand : SimpleCommand public class UnloadAllAssembliesCommand : SimpleCommand
{ {
public override void Execute(object parameter) public override void Execute(object parameter)

2
TestPlugin/Readme.txt

@ -1,7 +1,7 @@
ILSpy uses MEF (Managed Extensibility Framework) for plugins. ILSpy uses MEF (Managed Extensibility Framework) for plugins.
Plugins must be placed in the same directory as ILSpy.exe, and must be called "*.Plugin.dll". Plugins must be placed in the same directory as ILSpy.exe, and must be called "*.Plugin.dll".
To write a plugin, you need to add a reference to ILSpy.exe and to System.ComponentModel.Composition. To write a plugin, you need to add a reference to ILSpy.exe and to System.Composition.AttributedModel.
Depending on what your plugin is doing, you might also need references to the other libraries shipping with ILSpy. Depending on what your plugin is doing, you might also need references to the other libraries shipping with ILSpy.
Plugins work by exporting types for certain extension points. Plugins work by exporting types for certain extension points.

Loading…
Cancel
Save