Skip to content

Commit

Permalink
Annotate service lifetime explicitly.
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-englert committed Aug 12, 2024
1 parent b860ca3 commit 6c9d20a
Show file tree
Hide file tree
Showing 65 changed files with 137 additions and 6 deletions.
1 change: 0 additions & 1 deletion ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
<Rule Id="RECS0001" Action="Info" />
</Rules>
<Rules AnalyzerId="TomsToolbox.Composition.Analyzer" RuleNamespace="TomsToolbox.Composition.Analyzer">
<Rule Id="MEF001" Action="Info" />
<Rule Id="MEF006" Action="Hidden" />
</Rules>
</RuleSet>
2 changes: 2 additions & 0 deletions ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
namespace ILSpy.BamlDecompiler
{
[Export(typeof(IResourceNodeFactory))]
[PartCreationPolicy(CreationPolicy.Shared)]
public sealed class BamlResourceNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
Expand All @@ -44,6 +45,7 @@ public ITreeNode CreateNode(Resource resource)
}

[Export(typeof(IResourceFileHandler))]
[PartCreationPolicy(CreationPolicy.Shared)]
public sealed class BamlResourceFileHandler : IResourceFileHandler
{
public string EntryType => "Page";
Expand Down
1 change: 1 addition & 0 deletions ILSpy.ReadyToRun/ReadyToRunLanguage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void WriteReference(IMember member, string text, bool isDefinition = fals
#endif

[Export(typeof(Language))]
[PartCreationPolicy(CreationPolicy.Shared)]
internal class ReadyToRunLanguage : Language

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Debug)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Debug)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Debug)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Debug)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Release)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Release)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Release)

Exported classes should have one constructor marked with the ImportingConstructor attribute.

Check warning on line 99 in ILSpy.ReadyToRun/ReadyToRunLanguage.cs

View workflow job for this annotation

GitHub Actions / Build (Release)

Exported classes should have one constructor marked with the ImportingConstructor attribute.
{
private static readonly ConditionalWeakTable<MetadataFile, ReadyToRunReaderCacheEntry> readyToRunReaders = new ConditionalWeakTable<MetadataFile, ReadyToRunReaderCacheEntry>();
Expand Down
2 changes: 2 additions & 0 deletions ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.

using System.ComponentModel;
using System.ComponentModel.Composition;
using System.Windows.Controls;
using System.Xml.Linq;

Expand All @@ -26,6 +27,7 @@
namespace ICSharpCode.ILSpy.ReadyToRun
{
[ExportOptionPage(Title = nameof(global::ILSpy.ReadyToRun.Properties.Resources.ReadyToRun), Order = 40)]
[PartCreationPolicy(CreationPolicy.NonShared)]
partial class ReadyToRunOptionPage : UserControl, IOptionPage
{
public ReadyToRunOptionPage()
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/AboutPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.

using System;
using System.ComponentModel.Composition;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
Expand All @@ -36,6 +37,7 @@
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._About), MenuOrder = 99999)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class AboutPage : SimpleCommand
{
public override void Execute(object parameter)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Analyzers/AnalyzeCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.

using System;
using System.ComponentModel.Composition;
using System.Linq;

using ICSharpCode.Decompiler.Metadata;
Expand All @@ -27,6 +28,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)]
internal sealed class AnalyzeCommand : SimpleCommand, IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Analyzers/CopyAnalysisResultsContextMenuEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
// 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.Linq;
using System.Text;
using System.Windows;

namespace ICSharpCode.ILSpy.Analyzers
{
[ExportContextMenuEntry(Header = "Copy results", Category = "Analyze", Order = 200)]
[PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class CopyAnalysisResultsContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Analyzers/RemoveAnalyzeContextMenuEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +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.Linq;

namespace ICSharpCode.ILSpy.Analyzers
{
[ExportContextMenuEntry(Header = "Remove", Icon = "images/Delete", Category = "Analyze", Order = 200)]
[PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class RemoveAnalyzeContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/BrowseBackCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
// 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.Windows.Input;

using ICSharpCode.ILSpy.Properties;

namespace ICSharpCode.ILSpy
{
[ExportToolbarCommand(ToolTip = nameof(Resources.Back), ToolbarIcon = "Images/Back", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 0)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class BrowseBackCommand : CommandWrapper
{
public BrowseBackCommand()
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/BrowseForwardCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@
// 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.Windows.Input;

using ICSharpCode.ILSpy.Properties;

namespace ICSharpCode.ILSpy
{
[ExportToolbarCommand(ToolTip = nameof(Resources.Forward), ToolbarIcon = "Images/Forward", ToolbarCategory = nameof(Resources.Navigation), ToolbarOrder = 1)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class BrowseForwardCommand : CommandWrapper
{
public BrowseForwardCommand()
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/CheckForUpdatesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
// DEALINGS IN THE SOFTWARE.


using System.ComponentModel.Composition;

using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpyX.Settings;

namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._Help), Header = nameof(Resources._CheckUpdates), MenuOrder = 5000)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class CheckForUpdatesCommand : SimpleCommand
{
public override bool CanExecute(object parameter)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/CopyFullyQualifiedNameContextMenuEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +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.Windows;

using ICSharpCode.ILSpy.Properties;
Expand All @@ -23,6 +24,7 @@
namespace ICSharpCode.ILSpy
{
[ExportContextMenuEntry(Header = nameof(Resources.CopyName), Icon = "images/Copy", Order = 9999)]
[PartCreationPolicy(CreationPolicy.Shared)]
public class CopyFullyQualifiedNameContextMenuEntry : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/DecompileAllCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using System;
using System.Collections.Concurrent;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -34,6 +35,7 @@
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDecompile), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class DecompileAllCommand : SimpleCommand
{
public override bool CanExecute(object parameter)
Expand Down Expand Up @@ -86,6 +88,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)]
sealed class Decompile100TimesCommand : SimpleCommand
{
public override void Execute(object parameter)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/DecompileCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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.Linq;

using ICSharpCode.Decompiler.TypeSystem;
Expand All @@ -25,6 +26,7 @@
namespace ICSharpCode.ILSpy.Commands
{
[ExportContextMenuEntry(Header = nameof(Resources.Decompile), Order = 10)]
[PartCreationPolicy(CreationPolicy.Shared)]
class DecompileCommand : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/DecompileInNewViewCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Windows.Threading;

Expand All @@ -30,6 +31,7 @@
namespace ICSharpCode.ILSpy.Commands
{
[ExportContextMenuEntry(Header = nameof(Resources.DecompileToNewPanel), InputGestureText = "MMB", Icon = "images/Search", Category = nameof(Resources.Analyze), Order = 90)]
[PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class DecompileInNewViewCommand : IContextMenuEntry
{
public bool IsVisible(TextViewContext context)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/DisassembleAllCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using System;
using System.Collections.Concurrent;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Threading.Tasks;

Expand All @@ -30,6 +31,7 @@
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDisassemble), MenuCategory = nameof(Resources.Open), MenuOrder = 2.5)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class DisassembleAllCommand : SimpleCommand
{
public override bool CanExecute(object parameter)
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/ExitCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +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 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)]
sealed class ExitCommand : SimpleCommand
{
public override void Execute(object parameter)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/ExtractPackageEntryContextMenuEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.

using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand All @@ -34,6 +35,7 @@
namespace ICSharpCode.ILSpy
{
[ExportContextMenuEntry(Header = nameof(Resources.ExtractPackageEntry), Category = nameof(Resources.Save), Icon = "Images/Save")]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class ExtractPackageEntryContextMenuEntry : IContextMenuEntry
{
public void Execute(TextViewContext context)
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/GeneratePdbContextMenuEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.

using System;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Linq;
Expand All @@ -38,6 +39,7 @@
namespace ICSharpCode.ILSpy
{
[ExportContextMenuEntry(Header = nameof(Resources.GeneratePortable))]
[PartCreationPolicy(CreationPolicy.Shared)]
class GeneratePdbContextMenuEntry : IContextMenuEntry
{
public void Execute(TextViewContext context)
Expand Down Expand Up @@ -103,6 +105,7 @@ internal static void GeneratePdbForAssembly(LoadedAssembly assembly)
}

[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.GeneratePortable), MenuCategory = nameof(Resources.Save))]
[PartCreationPolicy(CreationPolicy.Shared)]
class GeneratePdbMainMenuEntry : SimpleCommand
{
public override bool CanExecute(object parameter)
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/ManageAssemblyListsCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
// DEALINGS IN THE SOFTWARE.


using System.ComponentModel.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)]
sealed class ManageAssemblyListsCommand : SimpleCommand
{
public override void Execute(object parameter)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/OpenCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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.Windows.Input;

using ICSharpCode.ILSpy.Properties;
Expand All @@ -24,6 +25,7 @@ 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)]
sealed class OpenCommand : CommandWrapper
{
public OpenCommand()
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/OpenFromGacCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
// 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 ICSharpCode.ILSpy.AppEnv;
using ICSharpCode.ILSpy.Properties;

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)]
sealed class OpenFromGacCommand : SimpleCommand
{
public override bool CanExecute(object parameter)
Expand Down
3 changes: 3 additions & 0 deletions ILSpy/Commands/Pdb2XmlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#if DEBUG

using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -34,6 +35,7 @@
namespace ICSharpCode.ILSpy
{
[ExportMainMenuCommand(ParentMenuID = nameof(Resources._File), Header = nameof(Resources.DEBUGDumpPDBAsXML), MenuCategory = nameof(Resources.Open), MenuOrder = 2.6)]
[PartCreationPolicy(CreationPolicy.Shared)]
sealed class Pdb2XmlCommand : SimpleCommand
{
public override bool CanExecute(object parameter)
Expand Down Expand Up @@ -70,6 +72,7 @@ internal static void Execute(IEnumerable<AssemblyTreeNode> nodes)
}

[ExportContextMenuEntry(Header = nameof(Resources.DEBUGDumpPDBAsXML))]
[PartCreationPolicy(CreationPolicy.Shared)]
class Pdb2XmlCommandContextMenuEntry : IContextMenuEntry
{
public void Execute(TextViewContext context)
Expand Down
2 changes: 2 additions & 0 deletions ILSpy/Commands/RefreshCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +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.Windows.Input;

using ICSharpCode.ILSpy.Properties;
Expand All @@ -24,6 +25,7 @@ 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)]
sealed class RefreshCommand : CommandWrapper
{
public RefreshCommand()
Expand Down
Loading

0 comments on commit 6c9d20a

Please sign in to comment.