diff --git a/.editorconfig b/.editorconfig
index b7d98cfea2..64d038bd68 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -12,7 +12,7 @@ indent_size = 2
[*.{yml,yaml}]
indent_style = space
indent_size = 2
-[*.csproj]
+[*.{csproj,props}]
indent_style = space
indent_size = 2
[*.config]
@@ -119,3 +119,53 @@ csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
+
+# Naming rules
+dotnet_naming_rule.constants_rule.severity = warning
+dotnet_naming_rule.constants_rule.style = upper_camel_case_style
+dotnet_naming_rule.constants_rule.symbols = constants_symbols
+dotnet_naming_rule.private_constants_rule.severity = warning
+dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style
+dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols
+dotnet_naming_rule.private_instance_fields_rule.severity = warning
+dotnet_naming_rule.private_instance_fields_rule.style = lower_camel_case_style
+dotnet_naming_rule.private_instance_fields_rule.symbols = private_instance_fields_symbols
+dotnet_naming_rule.private_static_fields_rule.severity = warning
+dotnet_naming_rule.private_static_fields_rule.style = lower_camel_case_style
+dotnet_naming_rule.private_static_fields_rule.symbols = private_static_fields_symbols
+dotnet_naming_rule.private_static_readonly_rule.severity = warning
+dotnet_naming_rule.private_static_readonly_rule.style = upper_camel_case_style
+dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols
+dotnet_naming_rule.public_static_fields_rule.severity = warning
+dotnet_naming_rule.public_static_fields_rule.style = lower_camel_case_style
+dotnet_naming_rule.public_static_fields_rule.symbols = public_static_fields_symbols
+dotnet_naming_rule.static_readonly_rule.severity = warning
+dotnet_naming_rule.static_readonly_rule.style = upper_camel_case_style
+dotnet_naming_rule.static_readonly_rule.symbols = static_readonly_symbols
+dotnet_naming_style.lower_camel_case_style.capitalization = camel_case
+dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case
+dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
+dotnet_naming_symbols.constants_symbols.applicable_kinds = field
+dotnet_naming_symbols.constants_symbols.required_modifiers = const
+dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private
+dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field
+dotnet_naming_symbols.private_constants_symbols.required_modifiers = const
+dotnet_naming_symbols.private_instance_fields_symbols.applicable_accessibilities = private
+dotnet_naming_symbols.private_instance_fields_symbols.applicable_kinds = field
+dotnet_naming_symbols.private_static_fields_symbols.applicable_accessibilities = private
+dotnet_naming_symbols.private_static_fields_symbols.applicable_kinds = field
+dotnet_naming_symbols.private_static_fields_symbols.required_modifiers = static
+dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private
+dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field
+dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = readonly,static
+dotnet_naming_symbols.public_static_fields_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
+dotnet_naming_symbols.public_static_fields_symbols.applicable_kinds = field
+dotnet_naming_symbols.public_static_fields_symbols.required_modifiers = static
+dotnet_naming_symbols.static_readonly_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected
+dotnet_naming_symbols.static_readonly_symbols.applicable_kinds = field
+dotnet_naming_symbols.static_readonly_symbols.required_modifiers = readonly,static
+
+# Errors and warnings
+
+# MEF006: No importing constructor
+dotnet_diagnostic.MEF006.severity = silent
diff --git a/BuildTools/format.bat b/BuildTools/format.bat
index be49dc68ce..74018f350f 100644
--- a/BuildTools/format.bat
+++ b/BuildTools/format.bat
@@ -1,3 +1,5 @@
@rem This file can be used to trigger the commit hook's formatting,
@rem modifying the local formatting even if not committing all changes.
-"%ProgramFiles%\Git\usr\bin\bash.exe" BuildTools\pre-commit --format
\ No newline at end of file
+pushd %~dp0\..
+"%ProgramFiles%\Git\usr\bin\bash.exe" BuildTools\pre-commit --format
+popd
\ No newline at end of file
diff --git a/Directory.Packages.props b/Directory.Packages.props
index 41b329b4af..0a153070f0 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -45,7 +45,12 @@
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset
index 66b1288eb4..053189fe10 100644
--- a/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset
+++ b/ICSharpCode.Decompiler/ICSharpCode.Decompiler.ruleset
@@ -79,4 +79,7 @@
+
+
+
\ No newline at end of file
diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs
index fa925c9b43..f19b23e413 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/AttributeAppliedToAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Linq;
using System.Reflection.Metadata;
using System.Threading;
@@ -29,6 +30,7 @@
namespace ICSharpCode.ILSpyX.Analyzers.Builtin
{
[ExportAnalyzer(Header = "Applied To", Order = 10)]
+ [PartCreationPolicy(CreationPolicy.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 e928f531a5..e01513d2a4 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/EventImplementedByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows events that implement an interface event.
///
[ExportAnalyzer(Header = "Implemented By", Order = 10)]
+ [PartCreationPolicy(CreationPolicy.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 5db8f0841b..55206ce811 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/EventOverriddenByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows events that override an event.
///
[ExportAnalyzer(Header = "Overridden By", Order = 20)]
+ [PartCreationPolicy(CreationPolicy.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 ba829b0fc2..ad02b999f2 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/FieldAccessAnalyzer.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
@@ -35,6 +36,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Finds methods where this field is read.
///
[ExportAnalyzer(Header = "Assigned By", Order = 20)]
+ [PartCreationPolicy(CreationPolicy.Shared)]
class AssignedByFieldAccessAnalyzer : FieldAccessAnalyzer
{
public AssignedByFieldAccessAnalyzer() : base(true) { }
@@ -44,6 +46,7 @@ public AssignedByFieldAccessAnalyzer() : base(true) { }
/// Finds methods where this field is written.
///
[ExportAnalyzer(Header = "Read By", Order = 10)]
+ [PartCreationPolicy(CreationPolicy.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 a25d48d86c..4090650d38 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MemberImplementsInterfaceAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +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)]
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 89da791ed6..644212fab3 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodImplementedByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows methods that implement an interface method.
///
[ExportAnalyzer(Header = "Implemented By", Order = 40)]
+ [PartCreationPolicy(CreationPolicy.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 ab9c4fe71f..c2156d846f 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodOverriddenByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows methods that override a method.
///
[ExportAnalyzer(Header = "Overridden By", Order = 30)]
+ [PartCreationPolicy(CreationPolicy.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 702d77a7d9..a2cb798280 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsedByAnalyzer.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
@@ -32,6 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that are used by a method.
///
[ExportAnalyzer(Header = "Used By", Order = 20)]
+ [PartCreationPolicy(CreationPolicy.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 2b361ec000..6c7576f7c8 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodUsesAnalyzer.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Linq;
using System.Reflection.Metadata;
@@ -32,6 +33,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that are used by a method.
///
[ExportAnalyzer(Header = "Uses", Order = 10)]
+ [PartCreationPolicy(CreationPolicy.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 a24787a880..58d70f3dae 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/MethodVirtualUsedByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
@@ -31,6 +32,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that are used by a method.
///
[ExportAnalyzer(Header = "Used By", Order = 20)]
+ [PartCreationPolicy(CreationPolicy.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 4188822f40..159d0cf5f4 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyImplementedByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows properties that implement an interface property.
///
[ExportAnalyzer(Header = "Implemented By", Order = 10)]
+ [PartCreationPolicy(CreationPolicy.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 1eb0d4a004..da0f9f8acd 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/PropertyOverriddenByAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
@@ -28,6 +29,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows properties that override a property.
///
[ExportAnalyzer(Header = "Overridden By", Order = 20)]
+ [PartCreationPolicy(CreationPolicy.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 3f4fd59b21..3a2acc8a19 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExposedByAnalyzer.cs
@@ -17,17 +17,18 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
+using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.ILSpyX.Analyzers.Builtin
{
- using ICSharpCode.Decompiler.TypeSystem;
-
///
/// Finds all entities that expose a type.
///
[ExportAnalyzer(Header = "Exposed By", Order = 40)]
+ [PartCreationPolicy(CreationPolicy.Shared)]
class TypeExposedByAnalyzer : IAnalyzer
{
public bool Show(ISymbol entity) => entity is ITypeDefinition;
@@ -143,4 +144,4 @@ bool TypeIsExposedBy(TypeDefinitionUsedVisitor visitor, IMethod method)
return visitor.Found;
}
}
-}
+}
\ No newline at end of file
diff --git a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs
index b557110212..2e28cd526a 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeExtensionMethodsAnalyzer.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using ICSharpCode.Decompiler.TypeSystem;
@@ -27,6 +28,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Finds all extension methods defined for a type.
///
[ExportAnalyzer(Header = "Extension Methods", Order = 50)]
+ [PartCreationPolicy(CreationPolicy.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 603f3e5b0f..03bf391557 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeInstantiatedByAnalyzer.cs
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
@@ -33,6 +34,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows methods that instantiate a type.
///
[ExportAnalyzer(Header = "Instantiated By", Order = 20)]
+ [PartCreationPolicy(CreationPolicy.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 e4a10801f2..b7a8a4147d 100644
--- a/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs
+++ b/ICSharpCode.ILSpyX/Analyzers/Builtin/TypeUsedByAnalyzer.cs
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
+using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Linq;
using System.Reflection.Metadata;
@@ -34,6 +35,7 @@ namespace ICSharpCode.ILSpyX.Analyzers.Builtin
/// Shows entities that use a type.
///
[ExportAnalyzer(Header = "Used By", Order = 30)]
+ [PartCreationPolicy(CreationPolicy.Shared)]
class TypeUsedByAnalyzer : IAnalyzer
{
public IEnumerable Analyze(ISymbol analyzedSymbol, AnalyzerContext context)
diff --git a/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs b/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs
index 79686bdbad..e34675fc3c 100644
--- a/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs
+++ b/ICSharpCode.ILSpyX/TreeView/SharpTreeNode.cs
@@ -182,7 +182,7 @@ public bool IsSelected {
#endregion
#region OnChildrenChanged
- internal protected virtual void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
+ protected internal virtual void OnChildrenChanged(NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
{
diff --git a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
index 32f71afa95..ecb1e25d14 100644
--- a/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
+++ b/ILSpy.BamlDecompiler/BamlResourceNodeFactory.cs
@@ -32,6 +32,7 @@
namespace ILSpy.BamlDecompiler
{
[Export(typeof(IResourceNodeFactory))]
+ [PartCreationPolicy(CreationPolicy.Shared)]
public sealed class BamlResourceNodeFactory : IResourceNodeFactory
{
public ITreeNode CreateNode(Resource resource)
@@ -44,6 +45,7 @@ public ITreeNode CreateNode(Resource resource)
}
[Export(typeof(IResourceFileHandler))]
+ [PartCreationPolicy(CreationPolicy.Shared)]
public sealed class BamlResourceFileHandler : IResourceFileHandler
{
public string EntryType => "Page";
diff --git a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs
index cadd1217bc..410e49b67e 100644
--- a/ILSpy.ReadyToRun/ReadyToRunLanguage.cs
+++ b/ILSpy.ReadyToRun/ReadyToRunLanguage.cs
@@ -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
{
private static readonly ConditionalWeakTable readyToRunReaders = new ConditionalWeakTable();
diff --git a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
index 53da7a71fe..fbe046ea4a 100644
--- a/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
+++ b/ILSpy.ReadyToRun/ReadyToRunOptionPage.xaml.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System.ComponentModel;
+using System.ComponentModel.Composition;
using System.Windows.Controls;
using System.Xml.Linq;
@@ -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()
diff --git a/ILSpy.sln b/ILSpy.sln
index 5d4e13a931..ce506f4d2c 100644
--- a/ILSpy.sln
+++ b/ILSpy.sln
@@ -36,6 +36,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.ILSpyX", "ICSha
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ICSharpCode.BamlDecompiler", "ICSharpCode.BamlDecompiler\ICSharpCode.BamlDecompiler.csproj", "{81A30182-3378-4952-8880-F44822390040}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D0858E90-DCD5-4FD9-AA53-7262FAB8BEDB}"
+ ProjectSection(SolutionItems) = preProject
+ .editorconfig = .editorconfig
+ Directory.Packages.props = Directory.Packages.props
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/ILSpy/AboutPage.cs b/ILSpy/AboutPage.cs
index b796fa3622..43303bf889 100644
--- a/ILSpy/AboutPage.cs
+++ b/ILSpy/AboutPage.cs
@@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
+using System.ComponentModel.Composition;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows;
@@ -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)
diff --git a/ILSpy/Analyzers/AnalyzeCommand.cs b/ILSpy/Analyzers/AnalyzeCommand.cs
index e221235e83..889e6afa0b 100644
--- a/ILSpy/Analyzers/AnalyzeCommand.cs
+++ b/ILSpy/Analyzers/AnalyzeCommand.cs
@@ -16,10 +16,9 @@
// 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.Linq;
-using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.ILSpy.Properties;
using ICSharpCode.ILSpy.TreeNodes;
@@ -27,8 +26,11 @@
namespace ICSharpCode.ILSpy.Analyzers
{
[ExportContextMenuEntry(Header = nameof(Resources.Analyze), Icon = "Images/Search", Category = nameof(Resources.Analyze), InputGestureText = "Ctrl+R", Order = 100)]
- internal sealed class AnalyzeCommand : SimpleCommand, IContextMenuEntry
+ [PartCreationPolicy(CreationPolicy.Shared)]
+ internal sealed class AnalyzeContextMenuCommand : IContextMenuEntry
{
+ private static readonly AnalyzerTreeViewModel AnalyzerTreeView = App.ExportProvider.GetExportedValue();
+
public bool IsVisible(TextViewContext context)
{
if (context.TreeView is AnalyzerTreeView && context.SelectedTreeNodes != null && context.SelectedTreeNodes.All(n => n.Parent.IsRoot))
@@ -41,70 +43,49 @@ public bool IsVisible(TextViewContext context)
public bool IsEnabled(TextViewContext context)
{
if (context.SelectedTreeNodes == null)
- return context.Reference != null && context.Reference.Reference is IEntity;
- foreach (IMemberTreeNode node in context.SelectedTreeNodes)
{
- if (!IsValidReference(node.Member))
- return false;
+ return context.Reference is { Reference: IEntity };
}
-
- return true;
+ return context.SelectedTreeNodes
+ .OfType()
+ .All(node => IsValidReference(node.Member));
}
- bool IsValidReference(object reference)
+ static bool IsValidReference(object reference)
{
- return reference is IEntity && !(reference is IField f && f.IsConst);
+ return reference is IEntity and not IField { IsConst: true };
}
public void Execute(TextViewContext context)
{
- AnalyzerTreeView analyzerTreeView = MainWindow.Instance.AnalyzerTreeView;
- if (analyzerTreeView == null)
- {
- return;
- }
if (context.SelectedTreeNodes != null)
{
- foreach (IMemberTreeNode node in context.SelectedTreeNodes)
+ foreach (var node in context.SelectedTreeNodes.OfType().ToArray())
{
- analyzerTreeView.Analyze(node.Member);
+ AnalyzerTreeView.Analyze(node.Member);
}
}
- else if (context.Reference != null && context.Reference.Reference is IEntity entity)
+ else if (context.Reference is { Reference: IEntity entity })
{
- analyzerTreeView.Analyze(entity);
+ AnalyzerTreeView.Analyze(entity);
}
}
+ }
+
+ internal sealed class AnalyzeCommand : SimpleCommand
+ {
+ private static readonly AnalyzerTreeViewModel AnalyzerTreeView = App.ExportProvider.GetExportedValue();
public override bool CanExecute(object parameter)
{
- AnalyzerTreeView analyzerTreeView = MainWindow.Instance.AnalyzerTreeView;
- if (analyzerTreeView != null && analyzerTreeView.IsKeyboardFocusWithin)
- {
- return analyzerTreeView.SelectedItems.OfType