From 66544e6208be9be6040715d6da08ff0a1b3ab0ef Mon Sep 17 00:00:00 2001 From: tom-englert Date: Sat, 19 Oct 2024 18:51:23 +0200 Subject: [PATCH 1/2] Migrate DI from Microsoft.VisualStudio.Composition to Microsoft.Extensions.DependencyInjection --- Directory.Packages.props | 3 +- ILSpy/App.xaml.cs | 106 +++++++++++------------- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 44 +++++----- ILSpy/ExportProviderAdapter.cs | 103 ----------------------- ILSpy/ExtensionMethods.cs | 44 +++++----- ILSpy/ILSpy.csproj | 3 +- 6 files changed, 103 insertions(+), 200 deletions(-) delete mode 100644 ILSpy/ExportProviderAdapter.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 02ecbcfbec..f207629a4b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -23,12 +23,12 @@ + - @@ -45,6 +45,7 @@ + diff --git a/ILSpy/App.xaml.cs b/ILSpy/App.xaml.cs index 0665244f3f..0ae19f9e17 100644 --- a/ILSpy/App.xaml.cs +++ b/ILSpy/App.xaml.cs @@ -23,7 +23,6 @@ using System.Linq; using System.Reflection; using System.Runtime.Loader; -using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Documents; @@ -36,8 +35,6 @@ using Medo.Application; -using Microsoft.VisualStudio.Composition; - using TomsToolbox.Wpf.Styles; using ICSharpCode.ILSpyX.TreeView; @@ -47,6 +44,11 @@ using System.Globalization; using System.Threading; +using Microsoft.Extensions.DependencyInjection; + +using TomsToolbox.Composition.MicrosoftExtensions; +using TomsToolbox.Essentials; + namespace ICSharpCode.ILSpy { /// @@ -59,10 +61,9 @@ public partial class App : Application public static IExportProvider ExportProvider { get; private set; } - internal class ExceptionData + internal record ExceptionData(Exception Exception) { - public Exception Exception; - public string PluginName; + public string PluginName { get; init; } } public App() @@ -80,6 +81,14 @@ public App() 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) { AppDomain.CurrentDomain.UnhandledException += ShowErrorBox; @@ -92,8 +101,6 @@ public App() Resources.RegisterDefaultStyles(); - InitializeMef().GetAwaiter().GetResult(); - // Register the export provider so that it can be accessed from WPF/XAML components. ExportProviderLocator.Register(ExportProvider); // Add data templates registered via MEF. @@ -103,7 +110,7 @@ public App() ThemeManager.Current.Theme = sessionSettings.Theme; 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), @@ -125,6 +132,13 @@ public App() 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().HandleSingleInstanceCommandLineArguments(e.Args).HandleExceptions(); static Assembly ResolvePluginDependencies(AssemblyLoadContext context, AssemblyName assemblyName) @@ -136,22 +150,17 @@ static Assembly ResolvePluginDependencies(AssemblyLoadContext context, AssemblyN return context.LoadFromAssemblyPath(assemblyFileName); } - private static async Task InitializeMef() + private static bool InitializeDependencyInjection(SettingsService settingsService) { // Add custom logic for resolution of dependencies. // This necessary because the AssemblyLoadContext.LoadFromAssemblyPath and related methods, // do not automatically load dependencies. 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 { - // Set up VS MEF. For now, only do MEF1 part discovery, since that was in use before. - // 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 services = new ServiceCollection(); + + var pluginDir = Path.GetDirectoryName(typeof(App).Module.FullyQualifiedName); if (pluginDir != null) { @@ -160,46 +169,39 @@ private static async Task InitializeMef() var name = Path.GetFileNameWithoutExtension(plugin); try { - var asm = AssemblyLoadContext.Default.LoadFromAssemblyPath(plugin); - var parts = await discovery.CreatePartsAsync(asm); - catalog = catalog.AddParts(parts); + var assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(plugin); + services.BindExports(assembly); } 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 - var xParts = await discovery.CreatePartsAsync(typeof(IAnalyzer).Assembly); - catalog = catalog.AddParts(xParts); + services.BindExports(typeof(IAnalyzer).Assembly); // Then from ILSpy itself - var createdParts = await discovery.CreatePartsAsync(Assembly.GetExecutingAssembly()); - catalog = catalog.AddParts(createdParts); - - // 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. - // catalog.WithDesktopSupport(); - // If/When any part needs to import ICompositionService, this will be needed: - // catalog.WithCompositionService(); - var config = CompositionConfiguration.Create(catalog); - 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 }); - } + services.BindExports(Assembly.GetExecutingAssembly()); + // Add the settings service + services.AddSingleton(settingsService); + + var serviceProvider = services.BuildServiceProvider(new ServiceProviderOptions { ValidateOnBuild = true }); + + ExportProvider = new ExportProviderAdapter(serviceProvider); + + return true; } 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 @@ protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); - var output = new StringBuilder(); - - if (StartupExceptions.FormatExceptions(output)) - { - MessageBox.Show(output.ToString(), "Sorry we crashed!"); - Environment.Exit(1); - } - - MainWindow = new MainWindow(); + MainWindow = new(); MainWindow.Show(); } diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs index b94668f14e..33570c34fc 100644 --- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs +++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs @@ -21,18 +21,17 @@ using System.Collections.Specialized; using System.ComponentModel; using System.ComponentModel.Composition; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; -using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Navigation; using System.Windows.Threading; -using ICSharpCode.Decompiler; using ICSharpCode.Decompiler.Documentation; using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.TypeSystem; @@ -160,13 +159,15 @@ private bool HandleCommandLineArguments(CommandLineArguments args) /// 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. /// - private void HandleCommandLineArgumentsAfterShowList(CommandLineArguments args, ISettingsProvider? spySettings = null) + private async Task HandleCommandLineArgumentsAfterShowList(CommandLineArguments args, ISettingsProvider? spySettings = null) { var sessionSettings = SettingsService.Instance.SessionSettings; var relevantAssemblies = commandLineLoadedAssemblies.ToList(); 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) { var searchPane = App.ExportProvider.GetExportedValue(); @@ -180,7 +181,7 @@ public async Task HandleSingleInstanceCommandLineArguments(string[] args) { var cmdArgs = CommandLineArguments.Create(args); - await Dispatcher.InvokeAsync(() => { + await Dispatcher.InvokeAsync(async () => { if (!HandleCommandLineArguments(cmdArgs)) return; @@ -192,11 +193,11 @@ await Dispatcher.InvokeAsync(() => { window.WindowState = WindowState.Normal; } - HandleCommandLineArgumentsAfterShowList(cmdArgs); + await HandleCommandLineArgumentsAfterShowList(cmdArgs); }); } - private async void NavigateOnLaunch(string? navigateTo, string[]? activeTreeViewPath, ISettingsProvider? spySettings, List relevantAssemblies) + private async Task NavigateOnLaunch(string? navigateTo, string[]? activeTreeViewPath, ISettingsProvider? spySettings, List relevantAssemblies) { var initialSelection = SelectedItem; if (navigateTo != null) @@ -386,26 +387,31 @@ public void Initialize() 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(), output)) + if (FormatExceptions(App.StartupExceptions.ToArray(), out var output)) { + output.Title = "Startup errors"; + + DockWorkspace.Instance.AddTabPage(); 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(); - var result = exceptions.FormatExceptions(stringBuilder); - if (result) - { - output.Write(stringBuilder.ToString()); - } - return result; + output = null; + + var result = exceptions.FormatExceptions(); + if (result.IsNullOrEmpty()) + return false; + + output = new(); + output.Write(result); + return true; + } private void ShowAssemblyList(string name) diff --git a/ILSpy/ExportProviderAdapter.cs b/ILSpy/ExportProviderAdapter.cs deleted file mode 100644 index d883248c4c..0000000000 --- a/ILSpy/ExportProviderAdapter.cs +++ /dev/null @@ -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 - -/// -/// Adapter for Microsoft.VisualStudio.Composition. to . -/// -public sealed class ExportProviderAdapter : IExportProvider -{ - private static readonly Type DefaultMetadataType = typeof(Dictionary); - - private readonly ExportProvider _exportProvider; - - /// - /// Initializes a new instance of the class. - /// - /// The export provider. - public ExportProviderAdapter(ExportProvider exportProvider) - { - _exportProvider = exportProvider; - } - - event EventHandler? IExportProvider.ExportsChanged { add { } remove { } } - - T IExportProvider.GetExportedValue(string? contractName) where T : class - { - return _exportProvider.GetExportedValue(contractName) ?? throw new InvalidOperationException($"No export found for type {typeof(T).FullName} with contract '{contractName}'"); - } - - T? IExportProvider.GetExportedValueOrDefault(string? contractName) where T : class - { - return _exportProvider.GetExportedValues(contractName).SingleOrDefault(); - } - - bool IExportProvider.TryGetExportedValue(string? contractName, [NotNullWhen(true)] out T? value) where T : class - { - value = _exportProvider.GetExportedValues(contractName).SingleOrDefault(); - - return !Equals(value, default(T)); - } - - IEnumerable IExportProvider.GetExportedValues(string? contractName) where T : class - { - return _exportProvider.GetExportedValues(contractName); - } - - IEnumerable IExportProvider.GetExportedValues(Type contractType, string? contractName) - { - return _exportProvider - .GetExports(contractType, DefaultMetadataType, contractName) - .Select(item => item.Value) - .ExceptNullItems(); - } - - IEnumerable> IExportProvider.GetExports(Type contractType, string? contractName) - { - return _exportProvider - .GetExports(contractType, DefaultMetadataType, contractName) - .Select(item => new ExportAdapter(() => item.Value, new MetadataAdapter((IDictionary)item.Metadata))); - } - - IEnumerable> IExportProvider.GetExports(string? contractName) where T : class - { - return _exportProvider - .GetExports(typeof(T), DefaultMetadataType, contractName) - .Select(item => new ExportAdapter(() => (T?)item.Value, new MetadataAdapter((IDictionary)item.Metadata))); - } - - IEnumerable> IExportProvider.GetExports(string? contractName) where T : class where TMetadataView : class - { - return _exportProvider - .GetExports(contractName) - .Select(item => new ExportAdapter(() => item.Value, item.Metadata)); - } -} \ No newline at end of file diff --git a/ILSpy/ExtensionMethods.cs b/ILSpy/ExtensionMethods.cs index 39d623fd9a..1d49f41ada 100644 --- a/ILSpy/ExtensionMethods.cs +++ b/ILSpy/ExtensionMethods.cs @@ -20,6 +20,7 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; @@ -166,34 +167,37 @@ public static double ToGray(this Color? color) return color?.R * 0.3 + color?.G * 0.6 + color?.B * 0.1 ?? 0.0; } - internal static bool FormatExceptions(this IList exceptions, StringBuilder output) + internal static string? FormatExceptions(this IList exceptions) { if (exceptions.Count == 0) - return false; - bool first = true; + return null; - foreach (var item in exceptions) - { - if (first) - first = false; - else - output.AppendLine("-------------------------------------------------"); + string delimiter = $"-------------------------------------------------{Environment.NewLine}"; + + return string.Join(delimiter, exceptions.Select(FormatException)); + } + + private static string FormatException(App.ExceptionData item) + { + var output = new StringBuilder(); + + if (!item.PluginName.IsNullOrEmpty()) output.AppendLine("Error(s) loading plugin: " + item.PluginName); - if (item.Exception is System.Reflection.ReflectionTypeLoadException exception) - { - foreach (var ex in exception.LoaderExceptions.ExceptNullItems()) - { - output.AppendLine(ex.ToString()); - output.AppendLine(); - } - } - else + + if (item.Exception is System.Reflection.ReflectionTypeLoadException exception) + { + foreach (var ex in exception.LoaderExceptions.ExceptNullItems()) { - 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) diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 9b0dd62593..5908e748df 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -45,10 +45,11 @@ - + + From 0be506bd4ecfb9d9cadbe2bc8a70d8d0c6c876bf Mon Sep 17 00:00:00 2001 From: tom-englert Date: Tue, 22 Oct 2024 05:41:52 +0200 Subject: [PATCH 2/2] Get rid of the heavy System.ComponentModel.Composition, replace with the lightweight System.Composition.AttributedModel --- .editorconfig | 2 -- Directory.Packages.props | 7 +++---- .../Builtin/AttributeAppliedToAnalyzer.cs | 4 ++-- .../Builtin/EventImplementedByAnalyzer.cs | 4 ++-- .../Analyzers/Builtin/EventOverriddenByAnalyzer.cs | 4 ++-- .../Analyzers/Builtin/FieldAccessAnalyzer.cs | 6 +++--- .../Builtin/MemberImplementsInterfaceAnalyzer.cs | 4 ++-- .../Builtin/MethodImplementedByAnalyzer.cs | 4 ++-- .../Builtin/MethodOverriddenByAnalyzer.cs | 4 ++-- .../Analyzers/Builtin/MethodUsedByAnalyzer.cs | 4 ++-- .../Analyzers/Builtin/MethodUsesAnalyzer.cs | 4 ++-- .../Builtin/MethodVirtualUsedByAnalyzer.cs | 4 ++-- .../Builtin/PropertyImplementedByAnalyzer.cs | 4 ++-- .../Builtin/PropertyOverriddenByAnalyzer.cs | 4 ++-- .../Analyzers/Builtin/TypeExposedByAnalyzer.cs | 4 ++-- .../Builtin/TypeExtensionMethodsAnalyzer.cs | 4 ++-- .../Builtin/TypeInstantiatedByAnalyzer.cs | 4 ++-- .../Analyzers/Builtin/TypeUsedByAnalyzer.cs | 4 ++-- .../Analyzers/ExportAnalyzerAttribute.cs | 2 +- ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj | 3 +-- ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs | 6 +++--- ILSpy.ReadyToRun/ReadyToRunLanguage.cs | 4 ++-- ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs | 8 ++++---- ILSpy/AboutPage.cs | 4 ++-- ILSpy/Analyzers/AnalyzeCommand.cs | 4 ++-- ILSpy/Analyzers/AnalyzerTreeView.xaml.cs | 6 +++--- ILSpy/Analyzers/AnalyzerTreeViewModel.cs | 4 ++-- .../CopyAnalysisResultsContextMenuEntry.cs | 4 ++-- ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs | 4 ++-- ILSpy/AssemblyTree/AssemblyListPane.xaml.cs | 6 +++--- ILSpy/AssemblyTree/AssemblyTreeModel.cs | 4 ++-- ILSpy/Commands/BrowseBackCommand.cs | 5 ++--- ILSpy/Commands/BrowseForwardCommand.cs | 5 ++--- ILSpy/Commands/CheckForUpdatesCommand.cs | 4 ++-- .../CopyFullyQualifiedNameContextMenuEntry.cs | 4 ++-- ILSpy/Commands/DecompileAllCommand.cs | 9 ++++----- ILSpy/Commands/DecompileCommand.cs | 4 ++-- ILSpy/Commands/DecompileInNewViewCommand.cs | 5 ++--- ILSpy/Commands/DisassembleAllCommand.cs | 4 ++-- ILSpy/Commands/ExitCommand.cs | 4 ++-- ILSpy/Commands/ExportCommandAttribute.cs | 2 +- .../ExtractPackageEntryContextMenuEntry.cs | 4 ++-- ILSpy/Commands/GeneratePdbContextMenuEntry.cs | 6 +++--- ILSpy/Commands/ManageAssemblyListsCommand.cs | 4 ++-- ILSpy/Commands/OpenCommand.cs | 5 ++--- ILSpy/Commands/OpenFromGacCommand.cs | 5 ++--- ILSpy/Commands/Pdb2XmlCommand.cs | 6 +++--- ILSpy/Commands/RefreshCommand.cs | 5 ++--- ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs | 8 +++----- ILSpy/Commands/SaveCodeContextMenuEntry.cs | 4 ++-- ILSpy/Commands/SaveCommand.cs | 5 ++--- ILSpy/Commands/ScopeSearchToAssembly.cs | 5 ++--- ILSpy/Commands/ScopeSearchToNamespace.cs | 5 ++--- ILSpy/Commands/SearchMsdnContextMenuEntry.cs | 4 ++-- ILSpy/Commands/SelectPdbContextMenuEntry.cs | 4 ++-- ILSpy/Commands/ShowCFGContextMenuEntry.cs | 4 ++-- ILSpy/Commands/SortAssemblyListCommand.cs | 6 +++--- ILSpy/ContextMenuEntry.cs | 2 +- ILSpy/Docking/CloseAllDocumentsCommand.cs | 6 +++--- ILSpy/ILSpy.csproj | 3 +-- ILSpy/Languages/CSharpILMixedLanguage.cs | 4 ++-- ILSpy/Languages/CSharpLanguage.cs | 7 +++---- ILSpy/Languages/ILLanguage.cs | 4 ++-- ILSpy/Metadata/GoToTokenCommand.cs | 6 +++--- ILSpy/Metadata/MetadataProtocolHandler.cs | 4 ++-- ILSpy/Options/DecompilerSettingsPanel.xaml.cs | 6 +++--- ILSpy/Options/DecompilerSettingsViewModel.cs | 4 ++-- ILSpy/Options/DisplaySettingsPanel.xaml.cs | 6 +++--- ILSpy/Options/DisplaySettingsViewModel.cs | 4 ++-- ILSpy/Options/MiscSettingsPanel.xaml.cs | 6 +++--- ILSpy/Options/MiscSettingsViewModel.cs | 4 ++-- ILSpy/Options/OptionsDialog.xaml.cs | 5 ++--- ILSpy/Search/SearchPane.xaml.cs | 8 ++++---- ILSpy/Search/SearchPaneModel.cs | 4 ++-- ILSpy/TextView/EditorCommands.cs | 6 +++--- ILSpy/TextView/FoldingCommands.cs | 6 +++--- ILSpy/TreeNodes/AssemblyTreeNode.cs | 14 +++++++------- .../ResourceNodes/CursorResourceEntryNode.cs | 4 ++-- .../ResourceNodes/IconResourceEntryNode.cs | 4 ++-- .../ResourceNodes/ImageListResourceEntryNode.cs | 4 ++-- .../ResourceNodes/ImageResourceEntryNode.cs | 4 ++-- .../ResourceNodes/ResourcesFileTreeNode.cs | 4 ++-- ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs | 4 ++-- ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs | 4 ++-- ILSpy/TreeNodes/ThreadingSupport.cs | 4 ++-- ILSpy/ViewModels/DebugStepsPaneModel.cs | 4 ++-- ILSpy/Views/DebugSteps.xaml.cs | 6 +++--- TestPlugin/AboutPageAddition.cs | 4 ++-- TestPlugin/ContextMenuCommand.cs | 4 ++-- TestPlugin/CustomLanguage.cs | 4 ++-- TestPlugin/CustomOptionPage.xaml.cs | 8 ++++---- TestPlugin/MainMenuCommand.cs | 4 ++-- TestPlugin/Readme.txt | 2 +- 93 files changed, 209 insertions(+), 228 deletions(-) diff --git a/.editorconfig b/.editorconfig index b2021e8c6a..1ea262ade4 100644 --- a/.editorconfig +++ b/.editorconfig @@ -147,5 +147,3 @@ dotnet_naming_rule.private_fields_rule.symbols = private_fields_symbols # MEF006: No importing constructor dotnet_diagnostic.MEF006.severity = silent -# MEF002: Import attributes, to be removed after final DI migration -dotnet_diagnostic.MEF002.severity = silent diff --git a/Directory.Packages.props b/Directory.Packages.props index f207629a4b..054032035e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -23,7 +23,7 @@ - + @@ -38,16 +38,15 @@ + - - - + diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs index f19b23e413..ba907ccb08 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection.Metadata; using System.Threading; @@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin { [ExportAnalyzer(Header = "Applied To", Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class AttributeAppliedToAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs index e01513d2a4..01ac66cc15 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows events that implement an interface event. /// [ExportAnalyzer(Header = "Implemented By", Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class EventImplementedByAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs index 55206ce811..bc6ea372a4 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows events that override an event. /// [ExportAnalyzer(Header = "Overridden By", Order = 20)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class EventOverriddenByAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs index ad02b999f2..64a0630da2 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Reflection.Metadata; @@ -36,7 +36,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Finds methods where this field is read. /// [ExportAnalyzer(Header = "Assigned By", Order = 20)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class AssignedByFieldAccessAnalyzer : FieldAccessAnalyzer { public AssignedByFieldAccessAnalyzer() : base(true) { } @@ -46,7 +46,7 @@ public AssignedByFieldAccessAnalyzer() : base(true) { } /// Finds methods where this field is written. /// [ExportAnalyzer(Header = "Read By", Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class ReadByFieldAccessAnalyzer : FieldAccessAnalyzer { public ReadByFieldAccessAnalyzer() : base(false) { } diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs index 4090650d38..e5bab201da 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows members from all corresponding interfaces the selected member implements. /// [ExportAnalyzer(Header = "Implements", Order = 40)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MemberImplementsInterfaceAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs index 644212fab3..811d35f8fd 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows methods that implement an interface method. /// [ExportAnalyzer(Header = "Implemented By", Order = 40)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MethodImplementedByAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs index c2156d846f..ee6390490a 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows methods that override a method. /// [ExportAnalyzer(Header = "Overridden By", Order = 30)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MethodOverriddenByAnalyzer : IAnalyzer { const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs index a2cb798280..93c0dd3953 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Reflection.Metadata; @@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows entities that are used by a method. /// [ExportAnalyzer(Header = "Used By", Order = 20)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MethodUsedByAnalyzer : IAnalyzer { const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs index 6c7576f7c8..7f4ce91447 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection.Metadata; @@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows entities that are used by a method. /// [ExportAnalyzer(Header = "Uses", Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MethodUsesAnalyzer : IAnalyzer { public bool Show(ISymbol symbol) => symbol is IMethod method && method.HasBody; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs index 58d70f3dae..41563988dc 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Reflection.Metadata; @@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows entities that are used by a method. /// [ExportAnalyzer(Header = "Used By", Order = 20)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MethodVirtualUsedByAnalyzer : IAnalyzer { const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs index 159d0cf5f4..fb26a3f5d6 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows properties that implement an interface property. /// [ExportAnalyzer(Header = "Implemented By", Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class PropertyImplementedByAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs index da0f9f8acd..34bbab114c 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows properties that override a property. /// [ExportAnalyzer(Header = "Overridden By", Order = 20)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class PropertyOverriddenByAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs index 3a2acc8a19..882b76ec8b 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using ICSharpCode.Decompiler.TypeSystem; @@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Finds all entities that expose a type. /// [ExportAnalyzer(Header = "Exposed By", Order = 40)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class TypeExposedByAnalyzer : IAnalyzer { public bool Show(ISymbol entity) => entity is ITypeDefinition; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs index 2e28cd526a..fbf8470a5f 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using ICSharpCode.Decompiler.TypeSystem; @@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Finds all extension methods defined for a type. /// [ExportAnalyzer(Header = "Extension Methods", Order = 50)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class TypeExtensionMethodsAnalyzer : IAnalyzer { public bool Show(ISymbol symbol) => symbol is ITypeDefinition entity && !entity.IsStatic; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs index fba95c1ddd..3145e0d9f9 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Reflection.Metadata; @@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows methods that instantiate a type. /// [ExportAnalyzer(Header = "Instantiated By", Order = 20)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class TypeInstantiatedByAnalyzer : IAnalyzer { const GetMemberOptions Options = GetMemberOptions.IgnoreInheritedMembers | GetMemberOptions.ReturnMemberDefinitions; diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs index b7a8a4147d..b0fc53fa28 100644 --- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs +++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Reflection.Metadata; @@ -35,7 +35,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin /// Shows entities that use a type. /// [ExportAnalyzer(Header = "Used By", Order = 30)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class TypeUsedByAnalyzer : IAnalyzer { public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context) diff --git a/ICSharpCode.ILSpyX/Analyzers/ExportAnalyzerAttribute.cs b/ICSharpCode.ILSpyX/Analyzers/ExportAnalyzerAttribute.cs index 628b41bc8f..563d7a05d5 100644 --- a/ICSharpCode.ILSpyX/Analyzers/ExportAnalyzerAttribute.cs +++ b/ICSharpCode.ILSpyX/Analyzers/ExportAnalyzerAttribute.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection; diff --git a/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj b/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj index 21a9363b0c..6ee7581b98 100644 --- a/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj +++ b/ICSharpCode.ILSpyX/ICSharpCode.ILSpyX.csproj @@ -66,10 +66,9 @@ - + - diff --git a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs index ecb1e25d14..29c54c1003 100644 --- a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs +++ b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using ICSharpCode.BamlDecompiler; @@ -32,7 +32,7 @@ namespace ILSpy.BamlDecompiler { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public sealed class BamlResourceNodeFactory : IResourceNodeFactory { public ITreeNode CreateNode(Resource resource) @@ -45,7 +45,7 @@ public ITreeNode CreateNode(Resource resource) } [Export(typeof(IResourceFileHandler))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public sealed class BamlResourceFileHandler : IResourceFileHandler { public string EntryType => "Page"; diff --git a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs index 6b0bff7386..78e4788616 100644 --- a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs +++ b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs @@ -20,7 +20,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.IO; using System.Linq; @@ -96,7 +96,7 @@ public void WriteReference(IMember member, string text, bool isDefinition = fals #endif [Export(typeof(Language))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal class ReadyToRunLanguage : Language { private static readonly ConditionalWeakTable readyToRunReaders = new ConditionalWeakTable(); diff --git a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs index d48d55ec1a..59aac573f1 100644 --- a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs +++ b/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 // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Options; using ICSharpCode.ILSpy.Util; using TomsToolbox.Wpf; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy.ReadyToRun { [DataTemplate(typeof(ReadyToRunOptionsViewModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] partial class ReadyToRunOptionPage { public ReadyToRunOptionPage() @@ -37,7 +37,7 @@ public ReadyToRunOptionPage() } [ExportOptionPage(Order = 40)] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] class ReadyToRunOptionsViewModel : ObservableObject, IOptionPage { private ReadyToRunOptions options; diff --git a/ILSpy/AboutPage.cs b/ILSpy/AboutPage.cs index 9d462e7537..5683b253de 100644 --- a/ILSpy/AboutPage.cs +++ b/ILSpy/AboutPage.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Text.RegularExpressions; using System.Windows; @@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._About), MenuOrder = 99999)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class AboutPage : SimpleCommand { public override void Execute(object parameter) diff --git a/ILSpy/Analyzers/AnalyzeCommand.cs b/ILSpy/Analyzers/AnalyzeCommand.cs index 9a24f29b24..e29dacb23e 100644 --- a/ILSpy/Analyzers/AnalyzeCommand.cs +++ b/ILSpy/Analyzers/AnalyzeCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using ICSharpCode.Decompiler.TypeSystem; @@ -26,7 +26,7 @@ namespace ICSharpCode.ILSpy.Analyzers { [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 { private static readonly AnalyzerTreeViewModel AnalyzerTreeView = App.ExportProvider.GetExportedValue(); diff --git a/ILSpy/Analyzers/AnalyzerTreeView.xaml.cs b/ILSpy/Analyzers/AnalyzerTreeView.xaml.cs index bff239a460..af2b186ebf 100644 --- a/ILSpy/Analyzers/AnalyzerTreeView.xaml.cs +++ b/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 // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Controls; using ICSharpCode.ILSpyX.TreeView; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy.Analyzers { @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpy.Analyzers /// Interaction logic for AnalyzerTreeView.xaml /// [DataTemplate(typeof(AnalyzerTreeViewModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] [Export] public partial class AnalyzerTreeView { diff --git a/ILSpy/Analyzers/AnalyzerTreeViewModel.cs b/ILSpy/Analyzers/AnalyzerTreeViewModel.cs index 5c666d38f4..ce45558b92 100644 --- a/ILSpy/Analyzers/AnalyzerTreeViewModel.cs +++ b/ILSpy/Analyzers/AnalyzerTreeViewModel.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Windows; using System.Windows.Input; @@ -32,7 +32,7 @@ namespace ICSharpCode.ILSpy.Analyzers { [ExportToolPane] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] [Export] public class AnalyzerTreeViewModel : ToolPaneModel { diff --git a/ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs b/ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs index 5d0af2d66f..c75447595c 100644 --- a/ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs +++ b/ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Text; using System.Windows; @@ -24,7 +24,7 @@ namespace ICSharpCode.ILSpy.Analyzers { [ExportContextMenuEntry(Header = "Copy results", Category = "Analyze", Order = 200)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal sealed class CopyAnalysisResultsContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs b/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs index 662f466ded..811c52fc32 100644 --- a/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs +++ b/ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs @@ -16,13 +16,13 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; namespace ICSharpCode.ILSpy.Analyzers { [ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete", Category = "Analyze", Order = 200)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal sealed class RemoveAnalyzeContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/AssemblyTree/AssemblyListPane.xaml.cs b/ILSpy/AssemblyTree/AssemblyListPane.xaml.cs index 93e78a75da..af7b14a918 100644 --- a/ILSpy/AssemblyTree/AssemblyListPane.xaml.cs +++ b/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 // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows; using System.Windows.Threading; using ICSharpCode.ILSpy.ViewModels; using ICSharpCode.ILSpyX.TreeView; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy.AssemblyTree { @@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree /// Interaction logic for AssemblyListPane.xaml /// [DataTemplate(typeof(AssemblyTreeModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public partial class AssemblyListPane { public AssemblyListPane() diff --git a/ILSpy/AssemblyTree/AssemblyTreeModel.cs b/ILSpy/AssemblyTree/AssemblyTreeModel.cs index 33570c34fc..954310192a 100644 --- a/ILSpy/AssemblyTree/AssemblyTreeModel.cs +++ b/ILSpy/AssemblyTree/AssemblyTreeModel.cs @@ -20,7 +20,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.ComponentModel; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; @@ -55,7 +55,7 @@ namespace ICSharpCode.ILSpy.AssemblyTree { [ExportToolPane] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] [Export] public class AssemblyTreeModel : ToolPaneModel { diff --git a/ILSpy/Commands/BrowseBackCommand.cs b/ILSpy/Commands/BrowseBackCommand.cs index ae53e19efc..d52f4d7345 100644 --- a/ILSpy/Commands/BrowseBackCommand.cs +++ b/ILSpy/Commands/BrowseBackCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Input; using ICSharpCode.ILSpy.AssemblyTree; @@ -25,12 +25,11 @@ namespace ICSharpCode.ILSpy { [ExportToolbarCommand(ToolTip = nameof(Resources.Back), ToolbarIcon = "Images/Back", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 0)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class BrowseBackCommand : CommandWrapper { readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public BrowseBackCommand(AssemblyTreeModel assemblyTreeModel) : base(NavigationCommands.BrowseBack) { diff --git a/ILSpy/Commands/BrowseForwardCommand.cs b/ILSpy/Commands/BrowseForwardCommand.cs index ea86ebc118..1eb2648568 100644 --- a/ILSpy/Commands/BrowseForwardCommand.cs +++ b/ILSpy/Commands/BrowseForwardCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Input; using ICSharpCode.ILSpy.AssemblyTree; @@ -25,12 +25,11 @@ namespace ICSharpCode.ILSpy { [ExportToolbarCommand(ToolTip = nameof(Resources.Forward), ToolbarIcon = "Images/Forward", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 1)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class BrowseForwardCommand : CommandWrapper { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public BrowseForwardCommand(AssemblyTreeModel assemblyTreeModel) : base(NavigationCommands.BrowseForward) { diff --git a/ILSpy/Commands/CheckForUpdatesCommand.cs b/ILSpy/Commands/CheckForUpdatesCommand.cs index 779f854a10..75ab702e73 100644 --- a/ILSpy/Commands/CheckForUpdatesCommand.cs +++ b/ILSpy/Commands/CheckForUpdatesCommand.cs @@ -17,14 +17,14 @@ // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._CheckUpdates), MenuOrder = 5000)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class CheckForUpdatesCommand : SimpleCommand { public override bool CanExecute(object parameter) diff --git a/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs b/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs index 47490e37bc..5cb06a1ead 100644 --- a/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs +++ b/ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs @@ -15,7 +15,7 @@ // 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.ComponentModel.Composition; +using System.Composition; using System.Windows; using ICSharpCode.ILSpy.Properties; @@ -24,7 +24,7 @@ namespace ICSharpCode.ILSpy { [ExportContextMenuEntry(Header = nameof(Resources.CopyName), Icon = "images/Copy", Order = 9999)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class CopyFullyQualifiedNameContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/Commands/DecompileAllCommand.cs b/ILSpy/Commands/DecompileAllCommand.cs index d719fa3c41..72aae604c5 100644 --- a/ILSpy/Commands/DecompileAllCommand.cs +++ b/ILSpy/Commands/DecompileAllCommand.cs @@ -21,7 +21,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; @@ -35,13 +35,12 @@ namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class DecompileAllCommand : SimpleCommand { private readonly IReadOnlyCollection resourceFileHandlers; - [ImportingConstructor] - public DecompileAllCommand([ImportMany] IEnumerable resourceFileHandlers) + public DecompileAllCommand(IEnumerable resourceFileHandlers) { this.resourceFileHandlers = resourceFileHandlers.ToArray(); } @@ -96,7 +95,7 @@ public override void Execute(object parameter) } [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile100x), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class Decompile100TimesCommand : SimpleCommand { public override void Execute(object parameter) diff --git a/ILSpy/Commands/DecompileCommand.cs b/ILSpy/Commands/DecompileCommand.cs index ec35a0cbee..13e8d429cb 100644 --- a/ILSpy/Commands/DecompileCommand.cs +++ b/ILSpy/Commands/DecompileCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using ICSharpCode.Decompiler.TypeSystem; @@ -26,7 +26,7 @@ namespace ICSharpCode.ILSpy.Commands { [ExportContextMenuEntry(Header = nameof(Resources.Decompile), Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class DecompileCommand : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/Commands/DecompileInNewViewCommand.cs b/ILSpy/Commands/DecompileInNewViewCommand.cs index 40df5145a1..107a11b46c 100644 --- a/ILSpy/Commands/DecompileInNewViewCommand.cs +++ b/ILSpy/Commands/DecompileInNewViewCommand.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Windows.Threading; @@ -34,12 +34,11 @@ namespace ICSharpCode.ILSpy.Commands { [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 { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public DecompileInNewViewCommand(AssemblyTreeModel assemblyTreeModel) { this.assemblyTreeModel = assemblyTreeModel; diff --git a/ILSpy/Commands/DisassembleAllCommand.cs b/ILSpy/Commands/DisassembleAllCommand.cs index 5ef572ee82..fea58925d9 100644 --- a/ILSpy/Commands/DisassembleAllCommand.cs +++ b/ILSpy/Commands/DisassembleAllCommand.cs @@ -20,7 +20,7 @@ using System; using System.Collections.Concurrent; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Threading.Tasks; @@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDisassemble), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class DisassembleAllCommand : SimpleCommand { public override bool CanExecute(object parameter) diff --git a/ILSpy/Commands/ExitCommand.cs b/ILSpy/Commands/ExitCommand.cs index fb475ef015..1ba8a34e1d 100644 --- a/ILSpy/Commands/ExitCommand.cs +++ b/ILSpy/Commands/ExitCommand.cs @@ -15,14 +15,14 @@ // 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.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.E_xit), MenuOrder = 99999, MenuCategory = nameof(Resources.Exit))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ExitCommand : SimpleCommand { public override void Execute(object parameter) diff --git a/ILSpy/Commands/ExportCommandAttribute.cs b/ILSpy/Commands/ExportCommandAttribute.cs index 19d100fd48..f368807f55 100644 --- a/ILSpy/Commands/ExportCommandAttribute.cs +++ b/ILSpy/Commands/ExportCommandAttribute.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Input; namespace ICSharpCode.ILSpy diff --git a/ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs b/ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs index 3f22fa1cdc..2d558aca41 100644 --- a/ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs +++ b/ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.IO; using System.Linq; @@ -35,7 +35,7 @@ namespace ICSharpCode.ILSpy { [ExportContextMenuEntry(Header = nameof(Resources.ExtractPackageEntry), Category = nameof(Resources.Save), Icon = "Images/Save")] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ExtractPackageEntryContextMenuEntry : IContextMenuEntry { public void Execute(TextViewContext context) diff --git a/ILSpy/Commands/GeneratePdbContextMenuEntry.cs b/ILSpy/Commands/GeneratePdbContextMenuEntry.cs index f410e8ada1..d31a3160c3 100644 --- a/ILSpy/Commands/GeneratePdbContextMenuEntry.cs +++ b/ILSpy/Commands/GeneratePdbContextMenuEntry.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.IO; using System.Linq; @@ -40,7 +40,7 @@ namespace ICSharpCode.ILSpy { [ExportContextMenuEntry(Header = nameof(Resources.GeneratePortable))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class GeneratePdbContextMenuEntry : IContextMenuEntry { public void Execute(TextViewContext context) @@ -107,7 +107,7 @@ internal static void GeneratePdbForAssembly(LoadedAssembly assembly) } [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.GeneratePortable), MenuCategory = nameof(Resources.Save))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class GeneratePdbMainMenuEntry : SimpleCommand { public override bool CanExecute(object parameter) diff --git a/ILSpy/Commands/ManageAssemblyListsCommand.cs b/ILSpy/Commands/ManageAssemblyListsCommand.cs index 0f2240e147..63ab2f0375 100644 --- a/ILSpy/Commands/ManageAssemblyListsCommand.cs +++ b/ILSpy/Commands/ManageAssemblyListsCommand.cs @@ -17,14 +17,14 @@ // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy { [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 { public override void Execute(object parameter) diff --git a/ILSpy/Commands/OpenCommand.cs b/ILSpy/Commands/OpenCommand.cs index 06ac419e90..2ea1608898 100644 --- a/ILSpy/Commands/OpenCommand.cs +++ b/ILSpy/Commands/OpenCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Input; 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)] [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 { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public OpenCommand(AssemblyTreeModel assemblyTreeModel) : base(ApplicationCommands.Open) { diff --git a/ILSpy/Commands/OpenFromGacCommand.cs b/ILSpy/Commands/OpenFromGacCommand.cs index 9d1c312148..c7fd898d04 100644 --- a/ILSpy/Commands/OpenFromGacCommand.cs +++ b/ILSpy/Commands/OpenFromGacCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.AppEnv; using ICSharpCode.ILSpy.AssemblyTree; @@ -25,12 +25,11 @@ namespace ICSharpCode.ILSpy { [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 { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public OpenFromGacCommand(AssemblyTreeModel assemblyTreeModel) { this.assemblyTreeModel = assemblyTreeModel; diff --git a/ILSpy/Commands/Pdb2XmlCommand.cs b/ILSpy/Commands/Pdb2XmlCommand.cs index b624124cbb..d4b9a7faeb 100644 --- a/ILSpy/Commands/Pdb2XmlCommand.cs +++ b/ILSpy/Commands/Pdb2XmlCommand.cs @@ -19,7 +19,7 @@ #if DEBUG using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -35,7 +35,7 @@ namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDumpPDBAsXML), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class Pdb2XmlCommand : SimpleCommand { public override bool CanExecute(object parameter) @@ -72,7 +72,7 @@ internal static void Execute(IEnumerable nodes) } [ExportContextMenuEntry(Header = nameof(Resources.DEBUGDumpPDBAsXML))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class Pdb2XmlCommandContextMenuEntry : IContextMenuEntry { public void Execute(TextViewContext context) diff --git a/ILSpy/Commands/RefreshCommand.cs b/ILSpy/Commands/RefreshCommand.cs index e01e70f0e8..d82ac11ab9 100644 --- a/ILSpy/Commands/RefreshCommand.cs +++ b/ILSpy/Commands/RefreshCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Input; 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)] [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 { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public RefreshCommand(AssemblyTreeModel assemblyTreeModel) : base(NavigationCommands.Refresh) { diff --git a/ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs b/ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs index b0bc068c88..42673e99a7 100644 --- a/ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs +++ b/ILSpy/Commands/RemoveAssembliesWithLoadErrors.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using ICSharpCode.ILSpy.AssemblyTree; @@ -25,12 +25,11 @@ namespace ICSharpCode.ILSpy { [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources._RemoveAssembliesWithLoadErrors), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class RemoveAssembliesWithLoadErrors : SimpleCommand { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public RemoveAssembliesWithLoadErrors(AssemblyTreeModel assemblyTreeModel) { this.assemblyTreeModel = assemblyTreeModel; @@ -55,12 +54,11 @@ public override void Execute(object parameter) } [ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.ClearAssemblyList), MenuCategory = nameof(Resources.Remove), MenuOrder = 2.6)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class ClearAssemblyList : SimpleCommand { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public ClearAssemblyList(AssemblyTreeModel assemblyTreeModel) { this.assemblyTreeModel = assemblyTreeModel; diff --git a/ILSpy/Commands/SaveCodeContextMenuEntry.cs b/ILSpy/Commands/SaveCodeContextMenuEntry.cs index c931ffe00d..14f9fdf503 100644 --- a/ILSpy/Commands/SaveCodeContextMenuEntry.cs +++ b/ILSpy/Commands/SaveCodeContextMenuEntry.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Linq; using System.Windows; @@ -34,7 +34,7 @@ namespace ICSharpCode.ILSpy.TextView { [ExportContextMenuEntry(Header = nameof(Resources._SaveCode), Category = nameof(Resources.Save), Icon = "Images/Save")] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class SaveCodeContextMenuEntry : IContextMenuEntry { public void Execute(TextViewContext context) diff --git a/ILSpy/Commands/SaveCommand.cs b/ILSpy/Commands/SaveCommand.cs index 9e43df69b6..3b1927e219 100644 --- a/ILSpy/Commands/SaveCommand.cs +++ b/ILSpy/Commands/SaveCommand.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Windows.Input; @@ -27,12 +27,11 @@ namespace ICSharpCode.ILSpy { [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 { private AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public SaveCommand(AssemblyTreeModel assemblyTreeModel) : base(ApplicationCommands.Save) { diff --git a/ILSpy/Commands/ScopeSearchToAssembly.cs b/ILSpy/Commands/ScopeSearchToAssembly.cs index 27f3c79f45..e1a42dd872 100644 --- a/ILSpy/Commands/ScopeSearchToAssembly.cs +++ b/ILSpy/Commands/ScopeSearchToAssembly.cs @@ -18,7 +18,7 @@ #nullable enable using System; -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.ILSpy.AppEnv; @@ -29,12 +29,11 @@ namespace ICSharpCode.ILSpy { [ExportContextMenuEntry(Header = nameof(Resources.ScopeSearchToThisAssembly), Category = nameof(Resources.Analyze), Order = 9999)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class ScopeSearchToAssembly : IContextMenuEntry { private readonly SearchPaneModel searchPane; - [ImportingConstructor] public ScopeSearchToAssembly(SearchPaneModel searchPane) { this.searchPane = searchPane; diff --git a/ILSpy/Commands/ScopeSearchToNamespace.cs b/ILSpy/Commands/ScopeSearchToNamespace.cs index 645f9d425e..31dec03499 100644 --- a/ILSpy/Commands/ScopeSearchToNamespace.cs +++ b/ILSpy/Commands/ScopeSearchToNamespace.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.ILSpy.AppEnv; @@ -27,12 +27,11 @@ namespace ICSharpCode.ILSpy { [ExportContextMenuEntry(Header = nameof(Resources.ScopeSearchToThisNamespace), Category = nameof(Resources.Analyze), Order = 9999)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class ScopeSearchToNamespace : IContextMenuEntry { private readonly SearchPaneModel searchPane; - [ImportingConstructor] public ScopeSearchToNamespace(SearchPaneModel searchPane) { this.searchPane = searchPane; diff --git a/ILSpy/Commands/SearchMsdnContextMenuEntry.cs b/ILSpy/Commands/SearchMsdnContextMenuEntry.cs index a49f1c456a..3dfa670320 100644 --- a/ILSpy/Commands/SearchMsdnContextMenuEntry.cs +++ b/ILSpy/Commands/SearchMsdnContextMenuEntry.cs @@ -23,12 +23,12 @@ using ICSharpCode.ILSpy.TreeNodes; namespace ICSharpCode.ILSpy { - using System.ComponentModel.Composition; + using System.Composition; using ICSharpCode.Decompiler.TypeSystem; [ExportContextMenuEntry(Header = nameof(Resources.SearchMSDN), Icon = "images/SearchMsdn", Order = 9999)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal sealed class SearchMsdnContextMenuEntry : IContextMenuEntry { private static string msdnAddress = "https://docs.microsoft.com/dotnet/api/{0}"; diff --git a/ILSpy/Commands/SelectPdbContextMenuEntry.cs b/ILSpy/Commands/SelectPdbContextMenuEntry.cs index db4fa73733..e64ec3881d 100644 --- a/ILSpy/Commands/SelectPdbContextMenuEntry.cs +++ b/ILSpy/Commands/SelectPdbContextMenuEntry.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Linq; @@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy { [ExportContextMenuEntry(Header = nameof(Resources.SelectPDB))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class SelectPdbContextMenuEntry : IContextMenuEntry { public async void Execute(TextViewContext context) diff --git a/ILSpy/Commands/ShowCFGContextMenuEntry.cs b/ILSpy/Commands/ShowCFGContextMenuEntry.cs index 2067752cc0..92d21c5cc7 100644 --- a/ILSpy/Commands/ShowCFGContextMenuEntry.cs +++ b/ILSpy/Commands/ShowCFGContextMenuEntry.cs @@ -1,6 +1,6 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Windows; using ICSharpCode.Decompiler.FlowAnalysis; @@ -11,7 +11,7 @@ namespace ICSharpCode.ILSpy.Commands { #if DEBUG [ExportContextMenuEntry(Header = "DEBUG -- Show CFG")] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal class ShowCFGContextMenuEntry : IContextMenuEntry { public void Execute(TextViewContext context) diff --git a/ILSpy/Commands/SortAssemblyListCommand.cs b/ILSpy/Commands/SortAssemblyListCommand.cs index 5b7dc67e1a..f3a55682dd 100644 --- a/ILSpy/Commands/SortAssemblyListCommand.cs +++ b/ILSpy/Commands/SortAssemblyListCommand.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Properties; 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))] [ExportToolbarCommand(ToolTip = nameof(Resources.SortAssemblyListName), ToolbarIcon = "Images/Sort", ToolbarCategory = nameof(Resources.View))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class SortAssemblyListCommand : SimpleCommand { public override void Execute(object parameter) @@ -39,7 +39,7 @@ public override void Execute(object parameter) [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))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class CollapseAllCommand : SimpleCommand { public override void Execute(object parameter) diff --git a/ILSpy/ContextMenuEntry.cs b/ILSpy/ContextMenuEntry.cs index 4da82c40d0..5d80ca5f18 100644 --- a/ILSpy/ContextMenuEntry.cs +++ b/ILSpy/ContextMenuEntry.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Windows; using System.Windows.Controls; diff --git a/ILSpy/Docking/CloseAllDocumentsCommand.cs b/ILSpy/Docking/CloseAllDocumentsCommand.cs index 14169498f4..c41f599435 100644 --- a/ILSpy/Docking/CloseAllDocumentsCommand.cs +++ b/ILSpy/Docking/CloseAllDocumentsCommand.cs @@ -1,11 +1,11 @@ -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy.Docking { [ExportMainMenuCommand(Header = nameof(Resources.Window_CloseAllDocuments), ParentMenuID = nameof(Resources._Window))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class CloseAllDocumentsCommand : SimpleCommand { public override void Execute(object parameter) @@ -15,7 +15,7 @@ public override void Execute(object parameter) } [ExportMainMenuCommand(Header = nameof(Resources.Window_ResetLayout), ParentMenuID = nameof(Resources._Window))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class ResetLayoutCommand : SimpleCommand { public override void Execute(object parameter) diff --git a/ILSpy/ILSpy.csproj b/ILSpy/ILSpy.csproj index 5908e748df..6bd46530f7 100644 --- a/ILSpy/ILSpy.csproj +++ b/ILSpy/ILSpy.csproj @@ -50,8 +50,7 @@ - - + diff --git a/ILSpy/Languages/CSharpILMixedLanguage.cs b/ILSpy/Languages/CSharpILMixedLanguage.cs index 4d3436d23d..93752eaefe 100644 --- a/ILSpy/Languages/CSharpILMixedLanguage.cs +++ b/ILSpy/Languages/CSharpILMixedLanguage.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.IO; using System.Linq; @@ -42,7 +42,7 @@ namespace ICSharpCode.ILSpy using SequencePoint = ICSharpCode.Decompiler.DebugInfo.SequencePoint; [Export(typeof(Language))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class CSharpILMixedLanguage : ILLanguage { public override string Name => "IL with C#"; diff --git a/ILSpy/Languages/CSharpLanguage.cs b/ILSpy/Languages/CSharpLanguage.cs index 4607877b3b..5725e05556 100644 --- a/ILSpy/Languages/CSharpLanguage.cs +++ b/ILSpy/Languages/CSharpLanguage.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Linq; using System.Reflection; @@ -52,7 +52,7 @@ namespace ICSharpCode.ILSpy /// please directly use the CSharpDecompiler class. /// [Export(typeof(Language))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class CSharpLanguage : Language { readonly IReadOnlyCollection resourceFileHandlers; @@ -61,8 +61,7 @@ public class CSharpLanguage : Language bool showAllMembers = false; int transformCount = int.MaxValue; - [ImportingConstructor] - public CSharpLanguage([ImportMany] IEnumerable resourceFileHandlers) + public CSharpLanguage(IEnumerable resourceFileHandlers) { this.resourceFileHandlers = resourceFileHandlers.ToArray(); } diff --git a/ILSpy/Languages/ILLanguage.cs b/ILSpy/Languages/ILLanguage.cs index 5bd8ee4e42..a857268f12 100644 --- a/ILSpy/Languages/ILLanguage.cs +++ b/ILSpy/Languages/ILLanguage.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection.Metadata; @@ -43,7 +43,7 @@ namespace ICSharpCode.ILSpy /// flat IL (detectControlStructure=false) and structured IL (detectControlStructure=true). /// [Export(typeof(Language))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class ILLanguage : Language { protected bool detectControlStructure = true; diff --git a/ILSpy/Metadata/GoToTokenCommand.cs b/ILSpy/Metadata/GoToTokenCommand.cs index 164f9b4514..7a1cc36814 100644 --- a/ILSpy/Metadata/GoToTokenCommand.cs +++ b/ILSpy/Metadata/GoToTokenCommand.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection; using System.Reflection.Metadata.Ecma335; @@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpy.Commands { [ExportContextMenuEntry(Header = nameof(Resources.GoToToken), Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class GoToTokenCommand : IContextMenuEntry { public void Execute(TextViewContext context) @@ -71,7 +71,7 @@ public bool IsVisible(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources.Copy), Order = 10)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class CopyCommand : IContextMenuEntry { public void Execute(TextViewContext context) diff --git a/ILSpy/Metadata/MetadataProtocolHandler.cs b/ILSpy/Metadata/MetadataProtocolHandler.cs index 8a50cac363..c3ffae68ef 100644 --- a/ILSpy/Metadata/MetadataProtocolHandler.cs +++ b/ILSpy/Metadata/MetadataProtocolHandler.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection.Metadata; @@ -26,7 +26,7 @@ namespace ICSharpCode.ILSpy.Metadata { [Export(typeof(IProtocolHandler))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] class MetadataProtocolHandler : IProtocolHandler { public ILSpyTreeNode Resolve(string protocol, MetadataFile module, Handle handle, out bool newTabPage) diff --git a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs b/ILSpy/Options/DecompilerSettingsPanel.xaml.cs index e65f72087c..f6266559ce 100644 --- a/ILSpy/Options/DecompilerSettingsPanel.xaml.cs +++ b/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 // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Xml.Linq; using ICSharpCode.ILSpyX.Settings; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy.Options { @@ -29,7 +29,7 @@ namespace ICSharpCode.ILSpy.Options /// Interaction logic for DecompilerSettingsPanel.xaml /// [DataTemplate(typeof(DecompilerSettingsViewModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] internal partial class DecompilerSettingsPanel { public DecompilerSettingsPanel() diff --git a/ILSpy/Options/DecompilerSettingsViewModel.cs b/ILSpy/Options/DecompilerSettingsViewModel.cs index 27cc520de5..a01fa15876 100644 --- a/ILSpy/Options/DecompilerSettingsViewModel.cs +++ b/ILSpy/Options/DecompilerSettingsViewModel.cs @@ -18,7 +18,7 @@ using System.Collections.Generic; using System.ComponentModel; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Reflection; @@ -30,7 +30,7 @@ namespace ICSharpCode.ILSpy.Options { [ExportOptionPage(Order = 10)] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public sealed class DecompilerSettingsViewModel : ObservableObjectBase, IOptionPage { private static readonly PropertyInfo[] propertyInfos = typeof(Decompiler.DecompilerSettings).GetProperties() diff --git a/ILSpy/Options/DisplaySettingsPanel.xaml.cs b/ILSpy/Options/DisplaySettingsPanel.xaml.cs index 3b51a16ba3..fdedbe5576 100644 --- a/ILSpy/Options/DisplaySettingsPanel.xaml.cs +++ b/ILSpy/Options/DisplaySettingsPanel.xaml.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Threading.Tasks; using System.Windows; @@ -29,7 +29,7 @@ using ICSharpCode.ILSpyX.Settings; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; using TomsToolbox.Wpf.Converters; namespace ICSharpCode.ILSpy.Options @@ -37,7 +37,7 @@ namespace ICSharpCode.ILSpy.Options /// /// Interaction logic for DisplaySettingsPanel.xaml /// - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] [DataTemplate(typeof(DisplaySettingsViewModel))] public partial class DisplaySettingsPanel { diff --git a/ILSpy/Options/DisplaySettingsViewModel.cs b/ILSpy/Options/DisplaySettingsViewModel.cs index 4d7c53f432..ad3361e51f 100644 --- a/ILSpy/Options/DisplaySettingsViewModel.cs +++ b/ILSpy/Options/DisplaySettingsViewModel.cs @@ -2,7 +2,7 @@ using System.Windows.Media; using System.Xml.Linq; using System; -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using System.Threading.Tasks; using System.Windows; @@ -13,7 +13,7 @@ namespace ICSharpCode.ILSpy.Options { [ExportOptionPage(Order = 20)] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public class DisplaySettingsViewModel : ObservableObject, IOptionPage { private DisplaySettings settings = new(); diff --git a/ILSpy/Options/MiscSettingsPanel.xaml.cs b/ILSpy/Options/MiscSettingsPanel.xaml.cs index d6c7c672d3..504fef89be 100644 --- a/ILSpy/Options/MiscSettingsPanel.xaml.cs +++ b/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 // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Controls; using System.Xml.Linq; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy.Options { @@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy.Options /// Interaction logic for MiscSettingsPanel.xaml /// [DataTemplate(typeof(MiscSettingsViewModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public partial class MiscSettingsPanel { public MiscSettingsPanel() diff --git a/ILSpy/Options/MiscSettingsViewModel.cs b/ILSpy/Options/MiscSettingsViewModel.cs index 2ed4b98681..b3e55f816a 100644 --- a/ILSpy/Options/MiscSettingsViewModel.cs +++ b/ILSpy/Options/MiscSettingsViewModel.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Reflection; using System.Windows; @@ -33,7 +33,7 @@ namespace ICSharpCode.ILSpy.Options { [ExportOptionPage(Order = 30)] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public class MiscSettingsViewModel : ObservableObject, IOptionPage { private MiscSettings settings; diff --git a/ILSpy/Options/OptionsDialog.xaml.cs b/ILSpy/Options/OptionsDialog.xaml.cs index 7834881758..1e56f86837 100644 --- a/ILSpy/Options/OptionsDialog.xaml.cs +++ b/ILSpy/Options/OptionsDialog.xaml.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.AssemblyTree; using ICSharpCode.ILSpy.Properties; @@ -58,12 +58,11 @@ public sealed class ExportOptionPageAttribute() : ExportAttribute("OptionPages", } [ExportMainMenuCommand(ParentMenuID = nameof(Resources._View), Header = nameof(Resources._Options), MenuCategory = nameof(Resources.Options), MenuOrder = 999)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ShowOptionsCommand : SimpleCommand { private readonly AssemblyTreeModel assemblyTreeModel; - [ImportingConstructor] public ShowOptionsCommand(AssemblyTreeModel assemblyTreeModel) { this.assemblyTreeModel = assemblyTreeModel; diff --git a/ILSpy/Search/SearchPane.xaml.cs b/ILSpy/Search/SearchPane.xaml.cs index 4c21ac145a..2702dac2f5 100644 --- a/ILSpy/Search/SearchPane.xaml.cs +++ b/ILSpy/Search/SearchPane.xaml.cs @@ -21,7 +21,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Text.RegularExpressions; using System.Threading; @@ -41,7 +41,7 @@ using TomsToolbox.Essentials; using TomsToolbox.Wpf; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy.Search { @@ -49,7 +49,7 @@ namespace ICSharpCode.ILSpy.Search /// Search pane /// [DataTemplate(typeof(SearchPaneModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public partial class SearchPane { const int MAX_RESULTS = 1000; @@ -535,7 +535,7 @@ AbstractSearchStrategy GetSearchStrategy(SearchRequest request) } [ExportToolbarCommand(ToolTip = nameof(Properties.Resources.SearchCtrlShiftFOrCtrlE), ToolbarIcon = "Images/Search", ToolbarCategory = nameof(Properties.Resources.View), ToolbarOrder = 100)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ShowSearchCommand : CommandWrapper { public ShowSearchCommand() diff --git a/ILSpy/Search/SearchPaneModel.cs b/ILSpy/Search/SearchPaneModel.cs index b3bc30c405..d598c03595 100644 --- a/ILSpy/Search/SearchPaneModel.cs +++ b/ILSpy/Search/SearchPaneModel.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows.Input; using System.Windows.Media; @@ -33,7 +33,7 @@ public class SearchModeModel } [ExportToolPane] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] [Export] public class SearchPaneModel : ToolPaneModel { diff --git a/ILSpy/TextView/EditorCommands.cs b/ILSpy/TextView/EditorCommands.cs index 0f6b5e6464..2e32d019f1 100644 --- a/ILSpy/TextView/EditorCommands.cs +++ b/ILSpy/TextView/EditorCommands.cs @@ -16,14 +16,14 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using ICSharpCode.ILSpy.Properties; namespace ICSharpCode.ILSpy.TextView { [ExportContextMenuEntry(Header = nameof(Resources.Copy), Category = nameof(Resources.Editor))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class CopyContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -43,7 +43,7 @@ public void Execute(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources.Select), Category = nameof(Resources.Editor))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class SelectAllContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/TextView/FoldingCommands.cs b/ILSpy/TextView/FoldingCommands.cs index c061c543e7..fd2566381d 100644 --- a/ILSpy/TextView/FoldingCommands.cs +++ b/ILSpy/TextView/FoldingCommands.cs @@ -16,7 +16,7 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using ICSharpCode.AvalonEdit; @@ -26,7 +26,7 @@ namespace ICSharpCode.ILSpy.TextView { [ExportContextMenuEntryAttribute(Header = nameof(Resources.ToggleFolding), Category = nameof(Resources.Folding))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal sealed class ToggleAllContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -63,7 +63,7 @@ public void Execute(TextViewContext context) } [ExportContextMenuEntryAttribute(Header = nameof(Resources._ToggleFolding), Category = nameof(Resources.Folding))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] internal sealed class ToggleContextMenuEntry : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/TreeNodes/AssemblyTreeNode.cs b/ILSpy/TreeNodes/AssemblyTreeNode.cs index b822a9ced7..ac1187d369 100644 --- a/ILSpy/TreeNodes/AssemblyTreeNode.cs +++ b/ILSpy/TreeNodes/AssemblyTreeNode.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Linq; using System.Threading.Tasks; @@ -580,7 +580,7 @@ public override string ToString() } [ExportContextMenuEntry(Header = nameof(Resources._Remove), Icon = "images/Delete")] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class RemoveAssembly : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -607,7 +607,7 @@ public void Execute(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources._Reload), Icon = "images/Refresh")] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ReloadAssembly : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -642,7 +642,7 @@ public void Execute(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources._LoadDependencies), Category = nameof(Resources.Dependencies))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class LoadDependencies : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -682,7 +682,7 @@ public async void Execute(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources._AddMainList), Category = nameof(Resources.Dependencies))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class AddToMainList : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -717,7 +717,7 @@ public void Execute(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources._OpenContainingFolder), Category = nameof(Resources.Shell))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class OpenContainingFolder : IContextMenuEntry { public bool IsVisible(TextViewContext context) @@ -770,7 +770,7 @@ public void Execute(TextViewContext context) } [ExportContextMenuEntry(Header = nameof(Resources._OpenCommandLineHere), Category = nameof(Resources.Shell))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class OpenCmdHere : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs index 993c22bdfc..e81ba4674c 100644 --- a/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/CursorResourceEntryNode.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Windows.Controls; using System.Windows.Media.Imaging; @@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.TreeNodes { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class CursorResourceNodeFactory : IResourceNodeFactory { static readonly string[] imageFileExtensions = { ".cur" }; diff --git a/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs index 075aa1ca02..e6720c7e77 100644 --- a/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/IconResourceEntryNode.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Windows.Controls; using System.Windows.Media.Imaging; @@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.TreeNodes { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class IconResourceNodeFactory : IResourceNodeFactory { public ITreeNode CreateNode(Resource resource) diff --git a/ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs index 7a3d9c7950..08a1062bc9 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ImageListResourceEntryNode.cs +++ b/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 // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Drawing; using System.IO; using System.Windows.Forms; @@ -28,7 +28,7 @@ namespace ICSharpCode.ILSpy.TreeNodes { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ImageListResourceEntryNodeFactory : IResourceNodeFactory { public ITreeNode CreateNode(Resource resource) diff --git a/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs b/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs index cad4098eb5..f33d3126cb 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/ImageResourceEntryNode.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Windows.Controls; using System.Windows.Media.Imaging; @@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.TreeNodes { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ImageResourceNodeFactory : IResourceNodeFactory { static readonly string[] imageFileExtensions = { ".png", ".gif", ".bmp", ".jpg" }; diff --git a/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs b/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs index 324390af2e..dec51e1839 100644 --- a/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/ResourcesFileTreeNode.cs @@ -19,7 +19,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Linq; @@ -38,7 +38,7 @@ namespace ICSharpCode.ILSpy.TreeNodes { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class ResourcesFileTreeNodeFactory : IResourceNodeFactory { public ITreeNode CreateNode(Resource resource) diff --git a/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs b/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs index e017948df8..342b2dec77 100644 --- a/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/XamlResourceNode.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Threading.Tasks; @@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.Xaml { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class XamlResourceNodeFactory : IResourceNodeFactory { public ITreeNode CreateNode(Resource resource) diff --git a/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs b/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs index 740947602a..c2e09d5f8f 100644 --- a/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs +++ b/ILSpy/TreeNodes/ResourceNodes/XmlResourceNode.cs @@ -17,7 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.ComponentModel.Composition; +using System.Composition; using System.IO; using System.Threading.Tasks; @@ -31,7 +31,7 @@ namespace ICSharpCode.ILSpy.Xaml { [Export(typeof(IResourceNodeFactory))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class XmlResourceNodeFactory : IResourceNodeFactory { private readonly static string[] xmlFileExtensions = { ".xml", ".xsd", ".xslt" }; diff --git a/ILSpy/TreeNodes/ThreadingSupport.cs b/ILSpy/TreeNodes/ThreadingSupport.cs index ce1d875154..c5d5ced632 100644 --- a/ILSpy/TreeNodes/ThreadingSupport.cs +++ b/ILSpy/TreeNodes/ThreadingSupport.cs @@ -18,7 +18,7 @@ using System; using System.Collections.Generic; -using System.ComponentModel.Composition; +using System.Composition; using System.Diagnostics; using System.Linq; using System.Text; @@ -172,7 +172,7 @@ public override void Decompile(Language language, ITextOutput output, Decompilat } [ExportContextMenuEntry(Header = nameof(Resources.CopyErrorMessage))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] sealed class CopyErrorMessageContextMenu : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/ILSpy/ViewModels/DebugStepsPaneModel.cs b/ILSpy/ViewModels/DebugStepsPaneModel.cs index 406f047a87..566786fa1e 100644 --- a/ILSpy/ViewModels/DebugStepsPaneModel.cs +++ b/ILSpy/ViewModels/DebugStepsPaneModel.cs @@ -16,14 +16,14 @@ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -using System.ComponentModel.Composition; +using System.Composition; using System.Windows; namespace ICSharpCode.ILSpy.ViewModels { #if DEBUG [ExportToolPane] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] #endif public class DebugStepsPaneModel : ToolPaneModel { diff --git a/ILSpy/Views/DebugSteps.xaml.cs b/ILSpy/Views/DebugSteps.xaml.cs index edd16a6d6d..7957802e51 100644 --- a/ILSpy/Views/DebugSteps.xaml.cs +++ b/ILSpy/Views/DebugSteps.xaml.cs @@ -1,6 +1,6 @@ using System; using System.ComponentModel; -using System.ComponentModel.Composition; +using System.Composition; using System.Windows; using System.Windows.Controls; using System.Windows.Input; @@ -10,12 +10,12 @@ using ICSharpCode.ILSpy.Docking; using ICSharpCode.ILSpy.ViewModels; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace ICSharpCode.ILSpy { [DataTemplate(typeof(DebugStepsPaneModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] public partial class DebugSteps : UserControl { static readonly ILAstWritingOptions writingOptions = new ILAstWritingOptions { diff --git a/TestPlugin/AboutPageAddition.cs b/TestPlugin/AboutPageAddition.cs index 4088b2f923..3a2baba5e9 100644 --- a/TestPlugin/AboutPageAddition.cs +++ b/TestPlugin/AboutPageAddition.cs @@ -1,7 +1,7 @@ // 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) -using System.ComponentModel.Composition; +using System.Composition; using System.Windows; using System.Windows.Media; @@ -11,7 +11,7 @@ namespace TestPlugin { [Export(typeof(IAboutPageAddition))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class AboutPageAddition : IAboutPageAddition { public void Write(ISmartTextOutput textOutput) diff --git a/TestPlugin/ContextMenuCommand.cs b/TestPlugin/ContextMenuCommand.cs index dad7dc3f6a..e7f4319fab 100644 --- a/TestPlugin/ContextMenuCommand.cs +++ b/TestPlugin/ContextMenuCommand.cs @@ -1,7 +1,7 @@ // 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) -using System.ComponentModel.Composition; +using System.Composition; using System.Linq; using ICSharpCode.ILSpy; @@ -10,7 +10,7 @@ namespace TestPlugin { [ExportContextMenuEntryAttribute(Header = "_Save Assembly")] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class SaveAssembly : IContextMenuEntry { public bool IsVisible(TextViewContext context) diff --git a/TestPlugin/CustomLanguage.cs b/TestPlugin/CustomLanguage.cs index 7e38fdffef..07b512ee2c 100644 --- a/TestPlugin/CustomLanguage.cs +++ b/TestPlugin/CustomLanguage.cs @@ -1,7 +1,7 @@ // 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) -using System.ComponentModel.Composition; +using System.Composition; using System.Reflection.Metadata; using System.Windows.Controls; @@ -15,7 +15,7 @@ namespace TestPlugin /// Adds a new language to the decompiler. /// [Export(typeof(Language))] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class CustomLanguage : Language { public override string Name { diff --git a/TestPlugin/CustomOptionPage.xaml.cs b/TestPlugin/CustomOptionPage.xaml.cs index c550e02c0f..95116a7439 100644 --- a/TestPlugin/CustomOptionPage.xaml.cs +++ b/TestPlugin/CustomOptionPage.xaml.cs @@ -1,19 +1,19 @@ // 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) -using System.ComponentModel.Composition; +using System.Composition; using System.Xml.Linq; using ICSharpCode.ILSpy.Options; using ICSharpCode.ILSpy.Util; using TomsToolbox.Wpf; -using TomsToolbox.Wpf.Composition.Mef; +using TomsToolbox.Wpf.Composition.AttributedModel; namespace TestPlugin { [DataTemplate(typeof(CustomOptionsViewModel))] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] partial class CustomOptionPage { public CustomOptionPage() @@ -23,7 +23,7 @@ public CustomOptionPage() } [ExportOptionPage(Order = 0)] - [PartCreationPolicy(CreationPolicy.NonShared)] + [NonShared] class CustomOptionsViewModel : ObservableObject, IOptionPage { private Options options; diff --git a/TestPlugin/MainMenuCommand.cs b/TestPlugin/MainMenuCommand.cs index 8c28e7fe1d..cddde39fd8 100644 --- a/TestPlugin/MainMenuCommand.cs +++ b/TestPlugin/MainMenuCommand.cs @@ -1,7 +1,7 @@ // 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) -using System.ComponentModel.Composition; +using System.Composition; 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. // 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)] - [PartCreationPolicy(CreationPolicy.Shared)] + [Shared] public class UnloadAllAssembliesCommand : SimpleCommand { public override void Execute(object parameter) diff --git a/TestPlugin/Readme.txt b/TestPlugin/Readme.txt index ab910e57af..2863fd6649 100644 --- a/TestPlugin/Readme.txt +++ b/TestPlugin/Readme.txt @@ -1,7 +1,7 @@ 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". -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. Plugins work by exporting types for certain extension points.