diff --git a/Build/ConvertToNetstandardReferences/ConvertToNetstandardReferences.cs b/Build/ConvertToNetstandardReferences/ConvertToNetstandardReferences.cs
index 683f756a4b..f2bdcf063a 100644
--- a/Build/ConvertToNetstandardReferences/ConvertToNetstandardReferences.cs
+++ b/Build/ConvertToNetstandardReferences/ConvertToNetstandardReferences.cs
@@ -50,7 +50,7 @@ bool ShouldPatchAssembly(string simpleName) {
}
static bool IsPublic(TypeDef type) {
- while (!(type is null)) {
+ while (type is not null) {
if (!type.IsPublic && !type.IsNestedPublic)
return false;
type = type.DeclaringType;
@@ -59,7 +59,7 @@ static bool IsPublic(TypeDef type) {
}
static bool IsPublic(ExportedType type) {
- while (!(type is null)) {
+ while (type is not null) {
if (!type.IsPublic && !type.IsNestedPublic)
return false;
type = type.DeclaringType;
diff --git a/DnSpyCommon.props b/DnSpyCommon.props
index 9bb1e450dd..c4ac11c7e9 100644
--- a/DnSpyCommon.props
+++ b/DnSpyCommon.props
@@ -13,7 +13,7 @@
falsetruestrict;nullablePublicOnly
- 8.0
+ latestlatestenfalse
diff --git a/Extensions/Examples/Example1.Extension/CodeCtxMenus.cs b/Extensions/Examples/Example1.Extension/CodeCtxMenus.cs
index bb8671f323..45a1c6f425 100644
--- a/Extensions/Examples/Example1.Extension/CodeCtxMenus.cs
+++ b/Extensions/Examples/Example1.Extension/CodeCtxMenus.cs
@@ -71,7 +71,7 @@ sealed class TextEditorCommand2 : MenuItemBase {
sealed class TextEditorCommand3 : MenuItemBase {
public override void Execute(IMenuItemContext context) {
var md = GetTokenObj(context);
- if (!(md is null)) {
+ if (md is not null) {
try {
Clipboard.SetText($"{md.MDToken.Raw:X8}");
}
@@ -101,14 +101,14 @@ public override void Execute(IMenuItemContext context) {
// Only show this in the document viewer
public override bool IsVisible(IMenuItemContext context) => context.CreatorObject.Guid == new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID);
- public override bool IsEnabled(IMenuItemContext context) => !(GetTokenObj(context) is null);
+ public override bool IsEnabled(IMenuItemContext context) => GetTokenObj(context) is not null;
}
[ExportMenuItem(Group = Constants.GROUP_TEXTEDITOR, Order = 30)]
sealed class TextEditorCommand4 : MenuItemBase {
public override void Execute(IMenuItemContext context) {
var documentViewer = GetDocumentViewer(context);
- if (!(documentViewer is null)) {
+ if (documentViewer is not null) {
try {
var lineColumn = GetLineColumn(documentViewer.Caret.Position.VirtualBufferPosition);
Clipboard.SetText($"Line,col: {lineColumn.Line + 1},{lineColumn.Column + 1}");
@@ -150,6 +150,6 @@ public LineColumn(int line, int column) {
// Only show this in the document viewer
public override bool IsVisible(IMenuItemContext context) => context.CreatorObject.Guid == new Guid(MenuConstants.GUIDOBJ_DOCUMENTVIEWERCONTROL_GUID);
- public override bool IsEnabled(IMenuItemContext context) => !(GetDocumentViewer(context) is null);
+ public override bool IsEnabled(IMenuItemContext context) => GetDocumentViewer(context) is not null;
}
}
diff --git a/Extensions/Examples/Example1.Extension/TreeViewCtxMenus.cs b/Extensions/Examples/Example1.Extension/TreeViewCtxMenus.cs
index 3bad57682a..bbb787d170 100644
--- a/Extensions/Examples/Example1.Extension/TreeViewCtxMenus.cs
+++ b/Extensions/Examples/Example1.Extension/TreeViewCtxMenus.cs
@@ -84,7 +84,7 @@ sealed class TVCommand4 : TVCtxMenuCommand {
sealed class TVCommand5 : TVCtxMenuCommand {
public override void Execute(TVContext context) {
var node = GetTokenNode(context);
- if (!(node is null)) {
+ if (node is not null) {
try {
Clipboard.SetText($"{node.Reference!.MDToken.Raw:X8}");
}
@@ -105,14 +105,14 @@ public override void Execute(TVContext context) {
return $"Copy token {node.Reference!.MDToken.Raw:X8}";
}
- public override bool IsVisible(TVContext context) => !(GetTokenNode(context) is null);
+ public override bool IsVisible(TVContext context) => GetTokenNode(context) is not null;
}
[ExportMenuItem(Header = "Copy Second Instruction", Group = Constants.GROUP_TREEVIEW, Order = 50)]
sealed class TVCommand6 : TVCtxMenuCommand {
public override void Execute(TVContext context) {
var instr = GetSecondInstruction(context);
- if (!(instr is null)) {
+ if (instr is not null) {
try {
Clipboard.SetText($"Second instruction: {instr}");
}
@@ -132,6 +132,6 @@ public override void Execute(TVContext context) {
return body.Instructions[1];
}
- public override bool IsEnabled(TVContext context) => !(GetSecondInstruction(context) is null);
+ public override bool IsEnabled(TVContext context) => GetSecondInstruction(context) is not null;
}
}
diff --git a/Extensions/Examples/Example2.Extension/AssemblyChildNodeTabContent.cs b/Extensions/Examples/Example2.Extension/AssemblyChildNodeTabContent.cs
index e8bb4dfd67..c72c7bf63c 100644
--- a/Extensions/Examples/Example2.Extension/AssemblyChildNodeTabContent.cs
+++ b/Extensions/Examples/Example2.Extension/AssemblyChildNodeTabContent.cs
@@ -28,7 +28,7 @@ sealed class AssemblyChildNodeTabContentFactory : IDocumentTabContentFactory {
// Serialize() doesn't add anything extra to 'section', but if it did, you'd have to
// get that info here and return null if the serialized data wasn't found.
var node = context.Nodes.Length == 1 ? context.Nodes[0] as AssemblyChildNode : null;
- if (!(node is null))
+ if (node is not null)
return new AssemblyChildNodeTabContent(node);
}
return null;
diff --git a/Extensions/Examples/Example2.Extension/NewDsDocument.cs b/Extensions/Examples/Example2.Extension/NewDsDocument.cs
index bca8eb679b..ecb5ab73f6 100644
--- a/Extensions/Examples/Example2.Extension/NewDsDocument.cs
+++ b/Extensions/Examples/Example2.Extension/NewDsDocument.cs
@@ -28,7 +28,7 @@ sealed class MyDsDocument : DsDocument {
// Used by MyDsDocumentNode.Decompile() to show the file in the text editor
public string Text {
get {
- if (!(text is null))
+ if (text is not null)
return text;
try {
return text = File.ReadAllText(Filename);
diff --git a/Extensions/Examples/Example2.Extension/OutputTextPane.cs b/Extensions/Examples/Example2.Extension/OutputTextPane.cs
index ff92b71b77..1488fd29c1 100644
--- a/Extensions/Examples/Example2.Extension/OutputTextPane.cs
+++ b/Extensions/Examples/Example2.Extension/OutputTextPane.cs
@@ -22,7 +22,7 @@ public static IOutputTextPane Instance {
return _instance;
}
set {
- if (!(_instance is null))
+ if (_instance is not null)
throw new InvalidOperationException("Can't initialize the logger twice");
_instance = value ?? throw new ArgumentNullException(nameof(value));
}
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/AssemblyInfoTransform.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/AssemblyInfoTransform.cs
index 58839a14a0..3be97f1ca8 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/AssemblyInfoTransform.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/AssemblyInfoTransform.cs
@@ -28,7 +28,7 @@ sealed class AssemblyInfoTransform : IAstTransform {
public void Run(AstNode compilationUnit) {
foreach (var attrSect in compilationUnit.Descendants.OfType()) {
var attr = attrSect.Descendants.OfType().FirstOrDefault();
- Debug2.Assert(!(attr is null));
+ Debug2.Assert(attr is not null);
if (attr is null)
continue;
bool remove = false;
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/CSharpDecompiler.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/CSharpDecompiler.cs
index bd0c255fbc..55b949f43e 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/CSharpDecompiler.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/CSharpDecompiler.cs
@@ -44,7 +44,7 @@ public DecompilerProvider()
}
public DecompilerProvider(DecompilerSettingsService decompilerSettingsService) {
- Debug2.Assert(!(decompilerSettingsService is null));
+ Debug2.Assert(decompilerSettingsService is not null);
this.decompilerSettingsService = decompilerSettingsService ?? throw new ArgumentNullException(nameof(decompilerSettingsService));
}
@@ -243,7 +243,7 @@ public override void Decompile(TypeDef type, IDecompilerOutput output, Decompila
void RunTransformsAndGenerateCode(ref BuilderState state, IDecompilerOutput output, DecompilationContext ctx, IAstTransform? additionalTransform = null) {
var astBuilder = state.AstBuilder;
astBuilder.RunTransformations(transformAbortCondition);
- if (!(additionalTransform is null)) {
+ if (additionalTransform is not null) {
additionalTransform.Run(astBuilder.SyntaxTree);
}
AddXmlDocumentation(ref state, langSettings.Settings, astBuilder);
@@ -256,7 +256,7 @@ internal static void AddXmlDocumentation(ref BuilderState state, DecompilerSetti
var hasXmlDocFileTmp = state.State.HasXmlDocFile(module);
bool hasXmlDocFile;
if (hasXmlDocFileTmp is null) {
- hasXmlDocFile = !(XmlDocLoader.LoadDocumentation(module) is null);
+ hasXmlDocFile = XmlDocLoader.LoadDocumentation(module) is not null;
state.State.SetHasXmlDocFile(module, hasXmlDocFile);
}
else
@@ -335,11 +335,11 @@ protected override void TypeToString(IDecompilerOutput output, ITypeDefOrRef? ty
static readonly UTF8String isReadOnlyAttributeString = new UTF8String("IsReadOnlyAttribute");
bool WriteRefIfByRef(IDecompilerOutput output, TypeSig typeSig, ParamDef? pd) {
if (typeSig.RemovePinnedAndModifiers() is ByRefSig) {
- if (!(pd is null) && (!pd.IsIn && pd.IsOut)) {
+ if (pd is not null && (!pd.IsIn && pd.IsOut)) {
output.Write("out", BoxedTextColor.Keyword);
output.Write(" ", BoxedTextColor.Text);
}
- else if (!(pd is null) && pd.IsDefined(systemRuntimeCompilerServicesString, isReadOnlyAttributeString)) {
+ else if (pd is not null && pd.IsDefined(systemRuntimeCompilerServicesString, isReadOnlyAttributeString)) {
output.Write("in", BoxedTextColor.Keyword);
output.Write(" ", BoxedTextColor.Text);
}
@@ -375,7 +375,7 @@ protected override void FormatPropertyName(IDecompilerOutput output, PropertyDef
}
if (isIndexer.Value) {
var accessor = property.GetMethod ?? property.SetMethod;
- if (!(accessor is null) && accessor.HasOverrides) {
+ if (accessor is not null && accessor.HasOverrides) {
var methDecl = accessor.Overrides.First().MethodDeclaration;
var declaringType = methDecl is null ? null : methDecl.DeclaringType;
TypeToString(output, declaringType, includeNamespace: true);
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompilePartialTransform.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompilePartialTransform.cs
index 56c2046809..ca9e5508d6 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompilePartialTransform.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompilePartialTransform.cs
@@ -43,13 +43,13 @@ public DecompilePartialTransform(TypeDef type, HashSet definitions,
public void Run(AstNode compilationUnit) {
foreach (var en in compilationUnit.Descendants.OfType()) {
var def = en.Annotation();
- Debug2.Assert(!(def is null));
+ Debug2.Assert(def is not null);
if (def is null)
continue;
if (def == type) {
var tdecl = en as TypeDeclaration;
- Debug2.Assert(!(tdecl is null));
- if (!(tdecl is null)) {
+ Debug2.Assert(tdecl is not null);
+ if (tdecl is not null) {
if (addPartialKeyword) {
if (tdecl.ClassType != ClassType.Enum)
tdecl.Modifiers |= Modifiers.Partial;
@@ -63,7 +63,7 @@ public void Run(AstNode compilationUnit) {
}
foreach (var iface in tdecl.BaseTypes) {
var tdr = iface.Annotation();
- if (!(tdr is null) && ifacesToRemove.Contains(tdr))
+ if (tdr is not null && ifacesToRemove.Contains(tdr))
iface.Remove();
}
}
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompileTypeMethodsTransform.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompileTypeMethodsTransform.cs
index dca66ea226..d7d7a718f4 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompileTypeMethodsTransform.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/CSharp/DecompileTypeMethodsTransform.cs
@@ -40,7 +40,7 @@ public DecompileTypeMethodsTransform(HashSet types, HashSet
foreach (var method in methods) {
// If it's part of a property or event, include the property or event since there are no partial props/events
var prop = method.DeclaringType.Properties.FirstOrDefault(a => a.GetMethods.Contains(method) || a.SetMethods.Contains(method));
- if (!(prop is null)) {
+ if (prop is not null) {
defsToShow.Add(prop);
foreach (var m in prop.GetMethods)
defsToShow.Add(m);
@@ -51,13 +51,13 @@ public DecompileTypeMethodsTransform(HashSet types, HashSet
}
else {
var evt = method.DeclaringType.Events.FirstOrDefault(a => a.AddMethod == method || a.RemoveMethod == method);
- if (!(evt is null)) {
+ if (evt is not null) {
defsToShow.Add(evt);
- if (!(evt.AddMethod is null))
+ if (evt.AddMethod is not null)
defsToShow.Add(evt.AddMethod);
- if (!(evt.RemoveMethod is null))
+ if (evt.RemoveMethod is not null)
defsToShow.Add(evt.RemoveMethod);
- if (!(evt.InvokeMethod is null))
+ if (evt.InvokeMethod is not null)
defsToShow.Add(evt.InvokeMethod);
foreach (var m in evt.OtherMethods)
defsToShow.Add(m);
@@ -73,7 +73,7 @@ public DecompileTypeMethodsTransform(HashSet types, HashSet
}
}
foreach (var def in defsToShow) {
- for (var declType = def.DeclaringType; !(declType is null); declType = declType.DeclaringType)
+ for (var declType = def.DeclaringType; declType is not null; declType = declType.DeclaringType)
partialTypes.Add(declType);
}
foreach (var type in types) {
@@ -88,14 +88,14 @@ public DecompileTypeMethodsTransform(HashSet types, HashSet
public void Run(AstNode compilationUnit) {
foreach (var en in compilationUnit.Descendants.OfType()) {
var def = en.Annotation();
- Debug2.Assert(!(def is null));
+ Debug2.Assert(def is not null);
if (def is null)
continue;
if (partialTypes.Contains(def)) {
var tdecl = en as TypeDeclaration;
- Debug2.Assert(!(tdecl is null));
- if (!(tdecl is null)) {
+ Debug2.Assert(tdecl is not null);
+ if (tdecl is not null) {
if (tdecl.ClassType != ClassType.Enum)
tdecl.Modifiers |= Modifiers.Partial;
if (!showDefinitions) {
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/IL/ILDecompiler.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/IL/ILDecompiler.cs
index 8e3c5aab59..8a28c63ed6 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/IL/ILDecompiler.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/IL/ILDecompiler.cs
@@ -40,7 +40,7 @@ public DecompilerProvider()
}
public DecompilerProvider(DecompilerSettingsService decompilerSettingsService) {
- Debug2.Assert(!(decompilerSettingsService is null));
+ Debug2.Assert(decompilerSettingsService is not null);
this.decompilerSettingsService = decompilerSettingsService ?? throw new ArgumentNullException(nameof(decompilerSettingsService));
}
@@ -89,7 +89,7 @@ ReflectionDisassembler CreateReflectionDisassembler(IDecompilerOutput output, De
var sb = new StringBuilder();
if (langSettings.Settings.ShowXmlDocumentation)
disOpts.GetXmlDocComments = a => GetXmlDocComments(a, sb);
- disOpts.CreateInstructionBytesReader = m => InstructionBytesReader.Create(m, !(ctx.IsBodyModified is null) && ctx.IsBodyModified(m));
+ disOpts.CreateInstructionBytesReader = m => InstructionBytesReader.Create(m, ctx.IsBodyModified is not null && ctx.IsBodyModified(m));
disOpts.ShowTokenAndRvaComments = langSettings.Settings.ShowTokenAndRvaComments;
disOpts.ShowILBytes = langSettings.Settings.ShowILBytes;
disOpts.SortMembers = langSettings.Settings.SortMembers;
@@ -111,7 +111,7 @@ static IEnumerable GetXmlDocComments(IMemberRef mr, StringBuilder sb) {
foreach (var info in new XmlDocLine(doc)) {
sb.Clear();
- if (!(info is null)) {
+ if (info is not null) {
sb.Append(' ');
info.Value.WriteTo(sb);
}
@@ -132,11 +132,11 @@ public override void Decompile(FieldDef field, IDecompilerOutput output, Decompi
public override void Decompile(PropertyDef property, IDecompilerOutput output, DecompilationContext ctx) {
ReflectionDisassembler rd = CreateReflectionDisassembler(output, ctx, property);
rd.DisassembleProperty(property, addLineSep: true);
- if (!(property.GetMethod is null)) {
+ if (property.GetMethod is not null) {
output.WriteLine();
rd.DisassembleMethod(property.GetMethod, true);
}
- if (!(property.SetMethod is null)) {
+ if (property.SetMethod is not null) {
output.WriteLine();
rd.DisassembleMethod(property.SetMethod, true);
}
@@ -149,11 +149,11 @@ public override void Decompile(PropertyDef property, IDecompilerOutput output, D
public override void Decompile(EventDef ev, IDecompilerOutput output, DecompilationContext ctx) {
ReflectionDisassembler rd = CreateReflectionDisassembler(output, ctx, ev);
rd.DisassembleEvent(ev, addLineSep: true);
- if (!(ev.AddMethod is null)) {
+ if (ev.AddMethod is not null) {
output.WriteLine();
rd.DisassembleMethod(ev.AddMethod, true);
}
- if (!(ev.RemoveMethod is null)) {
+ if (ev.RemoveMethod is not null) {
output.WriteLine();
rd.DisassembleMethod(ev.RemoveMethod, true);
}
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/ILAst/ILAstDecompiler.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/ILAst/ILAstDecompiler.cs
index 506ba385d8..66e505c774 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/ILAst/ILAstDecompiler.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/ILAst/ILAstDecompiler.cs
@@ -39,7 +39,7 @@ public DecompilerProvider()
}
public DecompilerProvider(DecompilerSettingsService decompilerSettingsService) {
- Debug2.Assert(!(decompilerSettingsService is null));
+ Debug2.Assert(decompilerSettingsService is not null);
this.decompilerSettingsService = decompilerSettingsService ?? throw new ArgumentNullException(nameof(decompilerSettingsService));
}
@@ -104,7 +104,7 @@ public override void Decompile(MethodDef method, IDecompilerOutput output, Decom
MethodDef? inlinedMethod = null;
AsyncMethodDebugInfo? asyncInfo = null;
string? compilerName = null;
- if (!(abortBeforeStep is null)) {
+ if (abortBeforeStep is not null) {
var optimizer = new ILAstOptimizer();
optimizer.Optimize(context, ilMethod, out stateMachineKind, out inlinedMethod, out asyncInfo, abortBeforeStep.Value);
compilerName = optimizer.CompilerName;
@@ -122,11 +122,11 @@ public override void Decompile(MethodDef method, IDecompilerOutput output, Decom
}
var allVariables = ilMethod.GetSelfAndChildrenRecursive().Select(e => e.Operand as ILVariable)
- .Where(v => !(v is null) && !v.IsParameter).Distinct();
+ .Where(v => v is not null && !v.IsParameter).Distinct();
foreach (var v in allVariables) {
- Debug2.Assert(!(v is null));
+ Debug2.Assert(v is not null);
output.Write(IdentifierEscaper.Escape(v.Name), v.GetTextReferenceObject(), DecompilerReferenceFlags.Local | DecompilerReferenceFlags.Definition, v.IsParameter ? BoxedTextColor.Parameter : BoxedTextColor.Local);
- if (!(v.Type is null)) {
+ if (v.Type is not null) {
output.Write(" ", BoxedTextColor.Text);
output.Write(":", BoxedTextColor.Punctuation);
output.Write(" ", BoxedTextColor.Text);
@@ -149,7 +149,7 @@ public override void Decompile(MethodDef method, IDecompilerOutput output, Decom
}
var localVariables = new HashSet(GetVariables(ilMethod));
- var builder = new MethodDebugInfoBuilder(settingsVersion, stateMachineKind, inlinedMethod ?? method, !(inlinedMethod is null) ? method : null, CreateSourceLocals(localVariables), CreateSourceParameters(localVariables), asyncInfo);
+ var builder = new MethodDebugInfoBuilder(settingsVersion, stateMachineKind, inlinedMethod ?? method, inlinedMethod is not null ? method : null, CreateSourceLocals(localVariables), CreateSourceParameters(localVariables), asyncInfo);
builder.CompilerName = compilerName;
foreach (ILNode node in ilMethod.Body) {
node.WriteTo(output, builder);
@@ -163,14 +163,14 @@ public override void Decompile(MethodDef method, IDecompilerOutput output, Decom
IEnumerable GetVariables(ILBlock ilMethod) {
foreach (var n in ilMethod.GetSelfAndChildrenRecursive(new List())) {
var expr = n as ILExpression;
- if (!(expr is null)) {
+ if (expr is not null) {
var v = expr.Operand as ILVariable;
- if (!(v is null))
+ if (v is not null)
yield return v;
continue;
}
var cb = n as ILTryCatchBlock.CatchBlockBase;
- if (!(cb is null) && !(cb.ExceptionVariable is null))
+ if (cb is not null && cb.ExceptionVariable is not null)
yield return cb.ExceptionVariable;
}
}
@@ -229,17 +229,17 @@ void EndKeywordBlock(IDecompilerOutput output, BraceInfo info, CodeBracesRangeFl
public override void Decompile(EventDef ev, IDecompilerOutput output, DecompilationContext ctx) {
var eventInfo = StartKeywordBlock(output, ".event", ev);
- if (!(ev.AddMethod is null)) {
+ if (ev.AddMethod is not null) {
var info = StartKeywordBlock(output, ".add", ev.AddMethod);
EndKeywordBlock(output, info, CodeBracesRangeFlags.AccessorBraces);
}
- if (!(ev.InvokeMethod is null)) {
+ if (ev.InvokeMethod is not null) {
var info = StartKeywordBlock(output, ".invoke", ev.InvokeMethod);
EndKeywordBlock(output, info, CodeBracesRangeFlags.AccessorBraces);
}
- if (!(ev.RemoveMethod is null)) {
+ if (ev.RemoveMethod is not null) {
var info = StartKeywordBlock(output, ".remove", ev.RemoveMethod);
EndKeywordBlock(output, info, CodeBracesRangeFlags.AccessorBraces);
}
@@ -252,7 +252,7 @@ public override void Decompile(FieldDef field, IDecompilerOutput output, Decompi
output.Write(" ", BoxedTextColor.Text);
output.Write(IdentifierEscaper.Escape(field.Name), field, DecompilerReferenceFlags.Definition, MetadataTextColorProvider.GetColor(field));
var c = field.Constant;
- if (!(c is null)) {
+ if (c is not null) {
output.Write(" ", BoxedTextColor.Text);
output.Write("=", BoxedTextColor.Operator);
output.Write(" ", BoxedTextColor.Text);
@@ -321,7 +321,7 @@ public override void Decompile(PropertyDef property, IDecompilerOutput output, D
public override void Decompile(TypeDef type, IDecompilerOutput output, DecompilationContext ctx) {
this.WriteCommentLine(output, $"Type: {type.FullName}");
- if (!(type.BaseType is null)) {
+ if (type.BaseType is not null) {
WriteCommentBegin(output, true);
output.Write("Base type: ", BoxedTextColor.Comment);
output.Write(IdentifierEscaper.Escape(type.BaseType.FullName), type.BaseType, DecompilerReferenceFlags.None, BoxedTextColor.Comment);
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/CSharpVBDecompilerSettings.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/CSharpVBDecompilerSettings.cs
index dfddc25a08..b474cedb10 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/CSharpVBDecompilerSettings.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/CSharpVBDecompilerSettings.cs
@@ -273,7 +273,7 @@ void SetMemberOrder(string s) {
public override bool Equals(object? obj) {
var other = obj as CSharpVBDecompilerSettings;
- return !(other is null) && decompilerSettings.Equals(other.decompilerSettings);
+ return other is not null && decompilerSettings.Equals(other.decompilerSettings);
}
public override int GetHashCode() => decompilerSettings.GetHashCode();
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/ILSettings.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/ILSettings.cs
index 9bf5a46082..1ba430d335 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/ILSettings.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/Settings/ILSettings.cs
@@ -146,7 +146,7 @@ public ILSettings CopyTo(ILSettings other) {
public override bool Equals(object? obj) {
var other = obj as ILSettings;
- return !(other is null) &&
+ return other is not null &&
ShowILComments == other.ShowILComments &&
ShowXmlDocumentation == other.ShowXmlDocumentation &&
ShowTokenAndRvaComments == other.ShowTokenAndRvaComments &&
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/ILSpyEnvironmentProvider.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/ILSpyEnvironmentProvider.cs
index 8c954b7cf2..54b037f347 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/ILSpyEnvironmentProvider.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/ILSpyEnvironmentProvider.cs
@@ -47,7 +47,7 @@ public string GetTypeNameForAttribute(ICSharpCode.NRefactory.CSharp.Attribute at
return null;
IEntity current = null;
-if (!(entity is null)) {
+if (entity is not null) {
var typeInfo = entity.Annotation();
current = loader.ReadTypeReference(typeInfo).Resolve(context).GetDefinition();
}
@@ -128,7 +128,7 @@ public TypeCode ResolveExpression(ICSharpCode.NRefactory.CSharp.Expression expre
}
}
- public bool HasEvent(ICSharpCode.NRefactory.VB.Ast.Expression expression) => !(expression.Annotation() is null);
+ public bool HasEvent(ICSharpCode.NRefactory.VB.Ast.Expression expression) => expression.Annotation() is not null;
public bool IsMethodGroup(ICSharpCode.NRefactory.CSharp.Expression expression) {
var annotation = expression.Annotation();
@@ -145,10 +145,10 @@ public ICSharpCode.NRefactory.CSharp.ParameterDeclaration[] GetParametersForProp
sb.Clear();
var getMethod = propInfo.GetMethod;
- if (!(getMethod is null))
+ if (getMethod is not null)
return getMethod.Parameters.Where(p => p.IsNormalMethodParameter).Select(p => new ICSharpCode.NRefactory.CSharp.ParameterDeclaration(AstBuilder.ConvertType(p.Type, sb), p.Name, GetModifiers(p))).ToArray();
var setMethod = propInfo.SetMethod;
- if (!(setMethod is null)) {
+ if (setMethod is not null) {
var ps = setMethod.Parameters.Where(p => p.IsNormalMethodParameter).ToArray();
if (ps.Length > 1)
return ps.Take(ps.Length - 1).Select(p => new ICSharpCode.NRefactory.CSharp.ParameterDeclaration(AstBuilder.ConvertType(p.Type, sb), p.Name, GetModifiers(p))).ToArray();
@@ -159,7 +159,7 @@ public ICSharpCode.NRefactory.CSharp.ParameterDeclaration[] GetParametersForProp
ICSharpCode.NRefactory.CSharp.ParameterModifier GetModifiers(Parameter p) {
var pd = p.ParamDef;
- if (!(pd is null)) {
+ if (pd is not null) {
if (pd.IsOut && pd.IsIn)
return ICSharpCode.NRefactory.CSharp.ParameterModifier.Ref;
if (pd.IsOut)
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBDecompiler.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBDecompiler.cs
index 63227b5fbc..dda8e7a8b4 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBDecompiler.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBDecompiler.cs
@@ -43,7 +43,7 @@ public DecompilerProvider()
}
public DecompilerProvider(DecompilerSettingsService decompilerSettingsService) {
- Debug2.Assert(!(decompilerSettingsService is null));
+ Debug2.Assert(decompilerSettingsService is not null);
this.decompilerSettingsService = decompilerSettingsService ?? throw new ArgumentNullException(nameof(decompilerSettingsService));
}
@@ -195,7 +195,7 @@ VBFormattingOptions CreateVBFormattingOptions(DecompilerSettings settings) =>
void RunTransformsAndGenerateCode(ref BuilderState state, IDecompilerOutput output, DecompilationContext ctx, IAstTransform? additionalTransform = null) {
var astBuilder = state.AstBuilder;
astBuilder.RunTransformations(transformAbortCondition);
- if (!(additionalTransform is null)) {
+ if (additionalTransform is not null) {
additionalTransform.Run(astBuilder.SyntaxTree);
}
var settings = GetDecompilerSettings();
@@ -249,7 +249,7 @@ void TypeToString(IDecompilerOutput output, ConvertTypeOptions options, ITypeDef
var converter = new CSharpToVBConverterVisitor(type.Module, envProvider);
var astType = AstBuilder.ConvertType(type, new StringBuilder(), typeAttributes, options);
- if (!(type.TryGetByRefSig() is null)) {
+ if (type.TryGetByRefSig() is not null) {
output.Write("ByRef", BoxedTextColor.Keyword);
output.Write(" ", BoxedTextColor.Text);
if (astType is ICSharpCode.NRefactory.CSharp.ComposedType && ((ICSharpCode.NRefactory.CSharp.ComposedType)astType).PointerRank > 0)
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBTextOutputFormatter.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBTextOutputFormatter.cs
index cdc5dbf8fb..bb0d4d3355 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBTextOutputFormatter.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/VisualBasic/VBTextOutputFormatter.cs
@@ -48,13 +48,13 @@ public void StartNode(AstNode node) {
nodeStack.Push(node);
MethodDebugInfoBuilder mapping = node.Annotation();
- if (!(mapping is null)) {
+ if (mapping is not null) {
parentMethodDebugInfoBuilder.Push(currentMethodDebugInfoBuilder);
currentMethodDebugInfoBuilder = mapping;
}
// For ctor/cctor field initializers
var mms = node.Annotation>>>();
- if (!(mms is null)) {
+ if (mms is not null) {
Debug2.Assert(multiMappings is null);
multiMappings = mms;
}
@@ -64,8 +64,8 @@ public void EndNode(AstNode node) {
if (nodeStack.Pop() != node)
throw new InvalidOperationException();
- if (!(node.Annotation() is null)) {
- Debug2.Assert(!(currentMethodDebugInfoBuilder is null));
+ if (node.Annotation() is not null) {
+ Debug2.Assert(currentMethodDebugInfoBuilder is not null);
if (context.CalculateILSpans) {
foreach (var ns in context.UsingNamespaces)
currentMethodDebugInfoBuilder.Scope.Imports.Add(ImportInfo.CreateNamespace(ns));
@@ -74,7 +74,7 @@ public void EndNode(AstNode node) {
currentMethodDebugInfoBuilder = parentMethodDebugInfoBuilder.Pop();
}
var mms = node.Annotation>>>();
- if (!(mms is null)) {
+ if (mms is not null) {
Debug.Assert(mms == multiMappings);
if (mms == multiMappings) {
foreach (var mm in mms)
@@ -86,25 +86,25 @@ public void EndNode(AstNode node) {
public void WriteIdentifier(string identifier, object data, object extraData) {
var definition = GetCurrentDefinition();
- if (!(definition is null)) {
+ if (definition is not null) {
output.Write(IdentifierEscaper.Escape(identifier), definition, DecompilerReferenceFlags.Definition, data);
return;
}
var memberRef = GetCurrentMemberReference() ?? (object?)(extraData as NamespaceReference);
- if (!(memberRef is null)) {
+ if (memberRef is not null) {
output.Write(IdentifierEscaper.Escape(identifier), memberRef, DecompilerReferenceFlags.None, data);
return;
}
definition = GetCurrentLocalDefinition();
- if (!(definition is null)) {
+ if (definition is not null) {
output.Write(IdentifierEscaper.Escape(identifier), definition, DecompilerReferenceFlags.Local | DecompilerReferenceFlags.Definition, data);
return;
}
memberRef = GetCurrentLocalReference();
- if (!(memberRef is null)) {
+ if (memberRef is not null) {
output.Write(IdentifierEscaper.Escape(identifier), memberRef, DecompilerReferenceFlags.Local, data);
return;
}
@@ -114,7 +114,7 @@ public void WriteIdentifier(string identifier, object data, object extraData) {
IMemberRef? GetCurrentMemberReference() {
AstNode node = nodeStack.Peek();
- if (!(node.Annotation() is null))
+ if (node.Annotation() is not null)
return null;
if (node.Role == AstNode.Roles.Type && node.Parent is ObjectCreationExpression)
node = node.Parent;
@@ -134,12 +134,12 @@ public void WriteIdentifier(string identifier, object data, object extraData) {
ILVariable variable = node.Annotation();
if (variable is null && node.Parent is IdentifierExpression)
variable = node.Parent.Annotation();
- if (!(variable is null))
+ if (variable is not null)
return variable.GetTextReferenceObject();
var lbl = (node.Parent?.Parent as GoToStatement)?.Label ?? (node.Parent?.Parent as LabelDeclarationStatement)?.Label;
- if (!(lbl is null)) {
- var method = nodeStack.Select(nd => nd.Annotation()).FirstOrDefault(mr => !(mr is null) && mr.IsMethod);
- if (!(method is null))
+ if (lbl is not null) {
+ var method = nodeStack.Select(nd => nd.Annotation()).FirstOrDefault(mr => mr is not null && mr.IsMethod);
+ if (method is not null)
return method.ToString() + lbl;
}
return null;
@@ -150,30 +150,30 @@ public void WriteIdentifier(string identifier, object data, object extraData) {
if (node is Identifier && node.Parent is CatchBlock)
node = node.Parent;
var parameterDef = node.Annotation();
- if (!(parameterDef is null))
+ if (parameterDef is not null)
return parameterDef;
if (node is ParameterDeclaration) {
node = ((ParameterDeclaration)node).Name;
parameterDef = node.Annotation();
- if (!(parameterDef is null))
+ if (parameterDef is not null)
return parameterDef;
}
if (node is VariableIdentifier) {
var variable = ((VariableIdentifier)node).Name.Annotation();
- if (!(variable is null))
+ if (variable is not null)
return variable.GetTextReferenceObject();
node = node.Parent ?? node;
}
if (node is VariableDeclaratorWithTypeAndInitializer || node is VariableInitializer || node is CatchBlock || node is ForEachStatement) {
var variable = node.Annotation();
- if (!(variable is null))
+ if (variable is not null)
return variable.GetTextReferenceObject();
}
if (node is LabelDeclarationStatement label) {
- var method = nodeStack.Select(nd => nd.Annotation()).FirstOrDefault(mr => !(mr is null) && mr.IsMethod);
- if (!(method is null))
+ var method = nodeStack.Select(nd => nd.Annotation()).FirstOrDefault(mr => mr is not null && mr.IsMethod);
+ if (method is not null)
return method.ToString() + label.Label;
}
@@ -205,18 +205,18 @@ public void WriteIdentifier(string identifier, object data, object extraData) {
public void WriteKeyword(string keyword) {
var memberRef = GetCurrentMemberReference();
var node = nodeStack.Peek();
- if (!(memberRef is null) && (node is PrimitiveType || node is InstanceExpression))
+ if (memberRef is not null && (node is PrimitiveType || node is InstanceExpression))
output.Write(keyword, memberRef, DecompilerReferenceFlags.None, BoxedTextColor.Keyword);
- else if (!(memberRef is null) && (node is ConstructorDeclaration && keyword == "New"))
+ else if (memberRef is not null && (node is ConstructorDeclaration && keyword == "New"))
output.Write(keyword, memberRef, DecompilerReferenceFlags.Local | DecompilerReferenceFlags.Definition, BoxedTextColor.Keyword);
- else if (!(memberRef is null) && (node is Accessor && (keyword == "Get" || keyword == "Set" || keyword == "AddHandler" || keyword == "RemoveHandler" || keyword == "RaiseEvent"))) {
+ else if (memberRef is not null && (node is Accessor && (keyword == "Get" || keyword == "Set" || keyword == "AddHandler" || keyword == "RemoveHandler" || keyword == "RaiseEvent"))) {
if (canPrintAccessor)
output.Write(keyword, memberRef, DecompilerReferenceFlags.Local | DecompilerReferenceFlags.Definition, BoxedTextColor.Keyword);
else
output.Write(keyword, BoxedTextColor.Keyword);
canPrintAccessor = !canPrintAccessor;
}
- else if (!(memberRef is null) && node is OperatorDeclaration && keyword == "Operator")
+ else if (memberRef is not null && node is OperatorDeclaration && keyword == "Operator")
output.Write(keyword, memberRef, DecompilerReferenceFlags.Definition, BoxedTextColor.Keyword);
else
output.Write(keyword, BoxedTextColor.Keyword);
@@ -227,7 +227,7 @@ public void WriteToken(string token, object data, object? reference) {
var memberRef = GetCurrentMemberReference();
var node = nodeStack.Peek();
- bool addRef = !(memberRef is null) &&
+ bool addRef = memberRef is not null &&
(node is BinaryOperatorExpression ||
node is UnaryOperatorExpression ||
node is AssignmentExpression);
@@ -235,13 +235,13 @@ node is UnaryOperatorExpression ||
// Add a ref to the method if it's a delegate call
if (!addRef && node is InvocationExpression && memberRef is IMethod) {
var md = Resolve(memberRef as IMethod);
- if (!(md is null) && !(md.DeclaringType is null) && md.DeclaringType.IsDelegate)
+ if (md is not null && md.DeclaringType is not null && md.DeclaringType.IsDelegate)
addRef = true;
}
if (addRef)
output.Write(token, memberRef, DecompilerReferenceFlags.None, data);
- else if (!(reference is null))
+ else if (reference is not null)
output.Write(token, reference, DecompilerReferenceFlags.Local | DecompilerReferenceFlags.Hidden | DecompilerReferenceFlags.NoFollow, data);
else
output.Write(token, data);
@@ -329,11 +329,11 @@ public void DebugExpression(AstNode node) {
public void DebugEnd(AstNode node) {
var state = debugStack.Pop();
- if (!(currentMethodDebugInfoBuilder is null)) {
+ if (currentMethodDebugInfoBuilder is not null) {
foreach (var ilSpan in ILSpan.OrderAndCompact(GetILSpans(state)))
currentMethodDebugInfoBuilder.Add(new SourceStatement(ilSpan, new TextSpan(state.StartLocation, output.NextPosition - state.StartLocation)));
}
- else if (!(multiMappings is null)) {
+ else if (multiMappings is not null) {
foreach (var mm in multiMappings) {
foreach (var ilSpan in ILSpan.OrderAndCompact(mm.Item2))
mm.Item1.Add(new SourceStatement(ilSpan, new TextSpan(state.StartLocation, output.NextPosition - state.StartLocation)));
@@ -356,8 +356,8 @@ static IEnumerable GetILSpans(DebugState state) {
}
public void AddHighlightedKeywordReference(object reference, int start, int end) {
- Debug2.Assert(!(reference is null));
- if (!(reference is null))
+ Debug2.Assert(reference is not null);
+ if (reference is not null)
output.AddSpanReference(reference, start, end, PredefinedSpanReferenceIds.HighlightRelatedKeywords);
}
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/AddXmlDocTransform.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/AddXmlDocTransform.cs
index 7173c8084a..9a30b183ca 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/AddXmlDocTransform.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/AddXmlDocTransform.cs
@@ -34,9 +34,9 @@ struct AddXmlDocTransform {
public void Run(AstNode node) {
if (node is EntityDeclaration) {
IMemberRef mr = node.Annotation();
- if (!(mr is null) && !(mr.Module is null)) {
+ if (mr is not null && mr.Module is not null) {
var xmldoc = XmlDocLoader.LoadDocumentation(mr.Module);
- if (!(xmldoc is null)) {
+ if (xmldoc is not null) {
var doc = xmldoc.GetDocumentation(XmlDocKeyProvider.GetKey(mr, stringBuilder));
if (!string2.IsNullOrEmpty(doc)) {
InsertXmlDocumentation(node, doc);
@@ -53,7 +53,7 @@ public void Run(AstNode node) {
void InsertXmlDocumentation(AstNode node, string doc) {
foreach (var info in new XmlDocLine(doc)) {
stringBuilder.Clear();
- if (!(info is null)) {
+ if (info is not null) {
stringBuilder.Append(' ');
info.Value.WriteTo(stringBuilder);
}
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/XmlDocLine.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/XmlDocLine.cs
index 92396f1dd5..638b017dda 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/XmlDocLine.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy.Core/XmlDoc/XmlDocLine.cs
@@ -105,7 +105,7 @@ public bool MoveNext() {
}
void Trim(out int trimmedIndex, out int trimmedEnd) {
- Debug2.Assert(!(indent is null));
+ Debug2.Assert(indent is not null);
int index = iter.Current.Index;
int end = index + iter.Current.Length;
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/CSharpDecompilerSettingsPage.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/CSharpDecompilerSettingsPage.cs
index b6ad7223a4..3d648e371b 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/CSharpDecompilerSettingsPage.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/CSharpDecompilerSettingsPage.cs
@@ -67,7 +67,7 @@ public DecompilationObjectVM DecompilationObject4 {
}
void SetDecompilationObject(int index, DecompilationObjectVM newValue) {
- Debug2.Assert(!(newValue is null));
+ Debug2.Assert(newValue is not null);
if (newValue is null)
throw new ArgumentNullException(nameof(newValue));
if (decompilationObjectVMs[index] == newValue)
diff --git a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/DecompilerAppSettingsModifiedListener.cs b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/DecompilerAppSettingsModifiedListener.cs
index 6040707787..aa2a648729 100644
--- a/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/DecompilerAppSettingsModifiedListener.cs
+++ b/Extensions/ILSpy.Decompiler/dnSpy.Decompiler.ILSpy/Settings/DecompilerAppSettingsModifiedListener.cs
@@ -58,7 +58,7 @@ public void OnSettingsModified(IAppRefreshSettings appRefreshSettings) {
get {
foreach (var tab in documentTabService.VisibleFirstTabs) {
var decompiler = (tab.Content as IDecompilerTabContent)?.Decompiler;
- if (!(decompiler is null))
+ if (decompiler is not null)
yield return (tab, decompiler);
}
}
diff --git a/Extensions/dnSpy.Analyzer/AnalyzerService.cs b/Extensions/dnSpy.Analyzer/AnalyzerService.cs
index 4dee71b017..ea108b2e2f 100644
--- a/Extensions/dnSpy.Analyzer/AnalyzerService.cs
+++ b/Extensions/dnSpy.Analyzer/AnalyzerService.cs
@@ -143,7 +143,7 @@ void DocumentTabService_FileModified(object? sender, DocumentModifiedEventArgs e
void ActivateNode() {
var nodes = TreeView.TopLevelSelection;
var node = nodes.Length == 0 ? null : nodes[0] as TreeNodeData;
- if (!(node is null))
+ if (node is not null)
node.Activate();
}
@@ -194,7 +194,7 @@ void AnalyzerSettings_PropertyChanged(object? sender, PropertyChangedEventArgs e
void ITreeViewListener.OnEvent(ITreeView treeView, TreeViewListenerEventArgs e) {
if (e.Event == TreeViewListenerEvent.NodeCreated) {
- Debug2.Assert(!(context is null));
+ Debug2.Assert(context is not null);
var node = (ITreeNode)e.Argument;
if (node.Data is AnalyzerTreeNodeData d)
d.Context = context;
@@ -213,7 +213,7 @@ void ClearAll() {
public void Add(AnalyzerTreeNodeData node) {
if (node is EntityNode an) {
var found = TreeView.Root.DataChildren.OfType().FirstOrDefault(n => n.Member == an.Member);
- if (!(found is null)) {
+ if (found is not null) {
found.TreeNode.IsExpanded = true;
TreeView.SelectItems(new TreeNodeData[] { found });
TreeView.Focus();
@@ -240,13 +240,13 @@ public void FollowNode(TreeNodeData node, bool newTab, bool? useCodeRef) {
var entityNode = node as EntityNode;
var srcRef = entityNode?.SourceRef;
- bool code = useCodeRef ?? !(srcRef is null);
+ bool code = useCodeRef ?? srcRef is not null;
if (code) {
if (srcRef is null)
return;
- if (!(srcRef.Value.ILOffset is null)) {
+ if (srcRef.Value.ILOffset is not null) {
documentTabService.FollowReference(srcRef.Value.Method, newTab, true, a => {
- if (!a.HasMovedCaret && a.Success && !(srcRef is null))
+ if (!a.HasMovedCaret && a.Success && srcRef is not null)
a.HasMovedCaret = GoTo(a.Tab, srcRef.Value.Method, srcRef.Value.ILOffset, srcRef.Value.Reference);
});
}
@@ -268,8 +268,8 @@ public bool CanFollowNode(TreeNodeData node, bool useCodeRef) {
var srcRef = entityNode?.SourceRef;
if (useCodeRef)
- return !(srcRef is null);
- return !(@ref is null);
+ return srcRef is not null;
+ return @ref is not null;
}
bool GoTo(IDocumentTab tab, MethodDef method, uint? ilOffset, object? @ref) {
@@ -354,7 +354,7 @@ static bool RefEquals(object? a, object? b) {
if (new SigComparer(flags).Equals(prop, b as PropertyDef))
return true;
var bm = b as IMethod;
- return !(bm is null) &&
+ return bm is not null &&
(new SigComparer(flags).Equals(prop.GetMethod, bm) ||
new SigComparer(flags).Equals(prop.SetMethod, bm));
}
@@ -363,7 +363,7 @@ static bool RefEquals(object? a, object? b) {
if (new SigComparer(flags).Equals(evt, b as EventDef))
return true;
var bm = b as IMethod;
- return !(bm is null) &&
+ return bm is not null &&
(new SigComparer(flags).Equals(evt.AddMethod, bm) ||
new SigComparer(flags).Equals(evt.InvokeMethod, bm) ||
new SigComparer(flags).Equals(evt.RemoveMethod, bm));
diff --git a/Extensions/dnSpy.Analyzer/Commands.cs b/Extensions/dnSpy.Analyzer/Commands.cs
index bd120da838..2e78ee98ff 100644
--- a/Extensions/dnSpy.Analyzer/Commands.cs
+++ b/Extensions/dnSpy.Analyzer/Commands.cs
@@ -49,7 +49,7 @@ public override void Execute(IMenuItemContext context) {
analyzerService.Value.FollowNode(@ref, newTab, useCodeRef);
}
- public override bool IsVisible(IMenuItemContext context) => !(GetReference(context) is null);
+ public override bool IsVisible(IMenuItemContext context) => GetReference(context) is not null;
TreeNodeData? GetReference(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID))
@@ -59,7 +59,7 @@ public override void Execute(IMenuItemContext context) {
if (nodes is null || nodes.Length != 1)
return null;
- if (nodes[0] is IMDTokenNode tokenNode && !(tokenNode.Reference is null)) {
+ if (nodes[0] is IMDTokenNode tokenNode && tokenNode.Reference is not null) {
if (!analyzerService.Value.CanFollowNode(nodes[0], useCodeRef))
return null;
return nodes[0];
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/AttributeAppliedToNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/AttributeAppliedToNode.cs
index 55260841fc..6023c202ff 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/AttributeAppliedToNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/AttributeAppliedToNode.cs
@@ -39,7 +39,7 @@ sealed class AttributeAppliedToNode : SearchNode {
public static bool CanShow(TypeDef type) => type.IsClass && IsCustomAttribute(type);
static bool IsCustomAttribute(TypeDef type) {
- while (!(type is null)) {
+ while (type is not null) {
var bt = type.BaseType.ResolveTypeDef();
if (bt is null)
return false;
@@ -55,7 +55,7 @@ public AttributeAppliedToNode(TypeDef analyzedType) {
analyzedTypes = new List { analyzedType };
includeAllModules = CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedType);
var ca = analyzedType.CustomAttributes.Find("System.AttributeUsageAttribute");
- if (!(ca is null) && ca.ConstructorArguments.Count == 1 && ca.ConstructorArguments[0].Value is int)
+ if (ca is not null && ca.ConstructorArguments.Count == 1 && ca.ConstructorArguments[0].Value is int)
usage = (AttributeTargets)ca.ConstructorArguments[0].Value;
else
usage = AttributeTargets.All;
@@ -104,7 +104,7 @@ IEnumerable FindReferencesInModule(IEnumerable
foreach (var module in modules) {
if ((usage & AttributeTargets.Assembly) != 0) {
AssemblyDef asm = module.Assembly;
- if (!(asm is null) && checkedAsms.Add(asm)) {
+ if (asm is not null && checkedAsms.Add(asm)) {
foreach (var attribute in asm.GetCustomAttributes()) {
if (new SigComparer().Equals(attribute.AttributeType?.GetScopeType(), trScopeType)) {
yield return new AssemblyNode(asm) { Context = Context };
@@ -267,10 +267,10 @@ IEnumerable FindReferencesWithinInType(TypeDef type, IType
var modules = Context.DocumentService.GetDocuments().Where(a => SearchNode.CanIncludeModule(mod, a.ModuleDef));
foreach (var module in modules) {
- Debug2.Assert(!(module.ModuleDef is null));
+ Debug2.Assert(module.ModuleDef is not null);
ct.ThrowIfCancellationRequested();
var typeref = GetScopeTypeRefInModule(module.ModuleDef);
- if (!(typeref is null))
+ if (typeref is not null)
yield return (module.ModuleDef, typeref);
}
}
@@ -288,11 +288,11 @@ IEnumerable FindReferencesWithinInType(TypeDef type, IType
var friendAssemblies = GetFriendAssemblies(Context.DocumentService, mod, out var modules);
if (friendAssemblies.Count > 0) {
foreach (var module in modules) {
- Debug2.Assert(!(module.ModuleDef is null));
+ Debug2.Assert(module.ModuleDef is not null);
ct.ThrowIfCancellationRequested();
if (module.AssemblyDef is null || friendAssemblies.Contains(module.AssemblyDef.Name)) {
var typeref = GetScopeTypeRefInModule(module.ModuleDef);
- if (!(typeref is null))
+ if (typeref is not null)
yield return (module.ModuleDef, typeref);
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/Commands.cs b/Extensions/dnSpy.Analyzer/TreeNodes/Commands.cs
index 88d4f09380..0b7dce0a3f 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/Commands.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/Commands.cs
@@ -133,7 +133,7 @@ sealed class FilesCommand : MenuItemBase {
if (nodes is null)
yield break;
- if (checkRoot && nodes.All(a => !(a.TreeNode.Parent is null) && a.TreeNode.Parent.Parent is null))
+ if (checkRoot && nodes.All(a => a.TreeNode.Parent is not null && a.TreeNode.Parent.Parent is null))
yield break;
foreach (var node in nodes) {
@@ -188,7 +188,7 @@ internal static IEnumerable GetMemberRefs(IMenuItemContext context,
yield break;
var @ref = context.Find();
- if (!(@ref is null)) {
+ if (@ref is not null) {
if (@ref.Reference is IMemberRef mr)
yield return mr;
}
@@ -251,13 +251,13 @@ public static void Analyze(IDsToolWindowService toolWindowService, Lazy DeleteNodes(), (s, e) => e.CanExecute = CanDeleteNodes, ModifierKeys.None, Key.Delete);
}
- bool CanDeleteNodes => !(GetNodes() is null);
+ bool CanDeleteNodes => GetNodes() is not null;
void DeleteNodes() => DeleteNodes(GetNodes());
TreeNodeData[]? GetNodes() => GetNodes(analyzerService.Value.TreeView.TopLevelSelection);
internal static TreeNodeData[]? GetNodes(TreeNodeData[] nodes) {
if (nodes is null)
return null;
- if (nodes.Length == 0 || !nodes.All(a => !(a.TreeNode.Parent is null) && a.TreeNode.Parent.Parent is null))
+ if (nodes.Length == 0 || !nodes.All(a => a.TreeNode.Parent is not null && a.TreeNode.Parent.Parent is null))
return null;
return nodes;
}
internal static void DeleteNodes(TreeNodeData[]? nodes) {
- if (!(nodes is null)) {
+ if (nodes is not null) {
foreach (var node in nodes) {
AnalyzerTreeNodeData.CancelSelfAndChildren(node);
node.TreeNode.Parent!.Children.Remove(node.TreeNode);
@@ -313,7 +313,7 @@ internal static void DeleteNodes(TreeNodeData[]? nodes) {
[ExportMenuItem(Header = "res:RemoveCommand", Icon = DsImagesAttribute.Cancel, InputGestureText = "res:ShortCutKeyDelete", Group = MenuConstants.GROUP_CTX_ANALYZER_OTHER, Order = 10)]
sealed class RemoveAnalyzeCtxMenuCommand : MenuItemBase {
- public override bool IsVisible(IMenuItemContext context) => !(GetNodes(context) is null);
+ public override bool IsVisible(IMenuItemContext context) => GetNodes(context) is not null;
static TreeNodeData[]? GetNodes(IMenuItemContext context) {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_ANALYZER_TREEVIEW_GUID))
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/EventAccessorNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/EventAccessorNode.cs
index c204a50c5f..b580111fcf 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/EventAccessorNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/EventAccessorNode.cs
@@ -28,7 +28,7 @@ public EventAccessorNode(MethodDef analyzedMethod, string? name)
: base(analyzedMethod) => this.name = name;
protected override void Write(ITextColorWriter output, IDecompiler decompiler) {
- if (!(name is null))
+ if (name is not null)
output.Write(BoxedTextColor.Keyword, name);
else
base.Write(output, decompiler);
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/EventFiredByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/EventFiredByNode.cs
index f16a721bd9..4c44373c5b 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/EventFiredByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/EventFiredByNode.cs
@@ -42,7 +42,7 @@ public EventFiredByNode(EventDef analyzedEvent) {
eventBackingField = GetBackingField(analyzedEvent);
var eventType = analyzedEvent.EventType.ResolveTypeDef();
- if (!(eventType is null))
+ if (eventType is not null)
eventFiringMethod = eventType.Methods.First(md => md.Name == "Invoke");
}
@@ -79,14 +79,14 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
if (readBackingField && (code == Code.Callvirt || code == Code.Call)) {
- if (instr.Operand is IMethod mr && !(eventFiringMethod is null) && mr.Name == eventFiringMethod.Name && CheckEquals(mr.ResolveMethodDef(), eventFiringMethod)) {
+ if (instr.Operand is IMethod mr && eventFiringMethod is not null && mr.Name == eventFiringMethod.Name && CheckEquals(mr.ResolveMethodDef(), eventFiringMethod)) {
foundInstr = instr;
break;
}
}
}
- if (!(foundInstr is null)) {
+ if (foundInstr is not null) {
if (GetOriginalCodeLocation(method) is MethodDef codeLocation && !HasAlreadyBeenFound(codeLocation)) {
var node = new MethodNode(codeLocation) { Context = Context };
if (codeLocation == method)
@@ -117,6 +117,6 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
- public static bool CanShow(EventDef ev) => !(GetBackingField(ev) is null);
+ public static bool CanShow(EventDef ev) => GetBackingField(ev) is not null;
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/EventNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/EventNode.cs
index a483d8bbe4..f366a0fdfc 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/EventNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/EventNode.cs
@@ -54,13 +54,13 @@ protected override void Write(ITextColorWriter output, IDecompiler decompiler) {
}
public override IEnumerable CreateChildren() {
- if (!(analyzedEvent.AddMethod is null))
+ if (analyzedEvent.AddMethod is not null)
yield return new EventAccessorNode(analyzedEvent.AddMethod, "add");
- if (!(analyzedEvent.RemoveMethod is null))
+ if (analyzedEvent.RemoveMethod is not null)
yield return new EventAccessorNode(analyzedEvent.RemoveMethod, "remove");
- if (!(analyzedEvent.InvokeMethod is null))
+ if (analyzedEvent.InvokeMethod is not null)
yield return new EventAccessorNode(analyzedEvent.InvokeMethod, "raise");
foreach (var accessor in analyzedEvent.OtherMethods)
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/EventOverriddenNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/EventOverriddenNode.cs
index e41f03fb7b..add3e73544 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/EventOverriddenNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/EventOverriddenNode.cs
@@ -68,18 +68,18 @@ protected override IEnumerable FetchChildren(CancellationT
}
public static bool CanShow(EventDef @event) =>
- !((GetAccessor(@event.AddMethod) ?? GetAccessor(@event.RemoveMethod) ?? GetAccessor(@event.InvokeMethod)) is null);
+ (GetAccessor(@event.AddMethod) ?? GetAccessor(@event.RemoveMethod) ?? GetAccessor(@event.InvokeMethod)) is not null;
static MethodDef? GetAccessor(MethodDef? accessor) {
- if (!(accessor is null) &&
- !(accessor.DeclaringType.BaseType is null) &&
+ if (accessor is not null &&
+ accessor.DeclaringType.BaseType is not null &&
(accessor.IsVirtual || accessor.IsAbstract) && accessor.IsReuseSlot)
return accessor;
return null;
}
static MethodDef? GetVirtualAccessor(MethodDef? accessor) {
- if (!(accessor is null) && (accessor.IsVirtual || accessor.IsAbstract))
+ if (accessor is not null && (accessor.IsVirtual || accessor.IsAbstract))
return accessor;
return null;
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/EventOverridesNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/EventOverridesNode.cs
index b80fa18b82..a43fa92b9b 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/EventOverridesNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/EventOverridesNode.cs
@@ -55,7 +55,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
public static bool CanShow(EventDef @event) {
var accessor = @event.AddMethod ?? @event.RemoveMethod ?? @event.InvokeMethod;
- return !(accessor is null) && accessor.IsVirtual && !accessor.IsFinal && !accessor.DeclaringType.IsInterface;
+ return accessor is not null && accessor.IsVirtual && !accessor.IsFinal && !accessor.DeclaringType.IsInterface;
}
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/FieldAccessNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/FieldAccessNode.cs
index f54c555894..67c92b416d 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/FieldAccessNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/FieldAccessNode.cs
@@ -85,7 +85,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(foundInstr is null)) {
+ if (foundInstr is not null) {
if (GetOriginalCodeLocation(method) is MethodDef codeLocation && !HasAlreadyBeenFound(codeLocation)) {
var node = new MethodNode(codeLocation) { Context = Context };
if (codeLocation == method)
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/Helpers.cs b/Extensions/dnSpy.Analyzer/TreeNodes/Helpers.cs
index 7af9bffcc7..2a00b5f14b 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/Helpers.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/Helpers.cs
@@ -46,7 +46,7 @@ static MethodDef GetOriginalCodeLocation(MethodDef method) {
/// Used to detect the 'parent method' for a lambda/iterator/async state machine.
///
static MethodDef? GetOriginalCodeLocation(TypeDef type) {
- if (!(type is null) && !(type.DeclaringType is null) && IsCompilerGenerated(type)) {
+ if (type is not null && type.DeclaringType is not null && IsCompilerGenerated(type)) {
if (type.IsValueType) {
// Value types might not have any constructor; but they must be stored in a local var
// because 'initobj' (or 'call .ctor') expects a managed ref.
@@ -107,12 +107,12 @@ internal static bool CheckEquals(IMemberRef? mr1, IMemberRef? mr2) =>
}
static TypeDef? ResolveWithinSameModule(ITypeDefOrRef type) {
- if (!(type is null) && type.Scope == type.Module)
+ if (type is not null && type.Scope == type.Module)
return type.ResolveTypeDef();
return null;
}
static bool IsCompilerGenerated(this IHasCustomAttribute hca) =>
- !(hca is null) && hca.CustomAttributes.IsDefined("System.Runtime.CompilerServices.CompilerGeneratedAttribute");
+ hca is not null && hca.CustomAttributes.IsDefined("System.Runtime.CompilerServices.CompilerGeneratedAttribute");
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceEventImplementedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceEventImplementedByNode.cs
index 742dbd3409..8ac48440e3 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceEventImplementedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceEventImplementedByNode.cs
@@ -39,11 +39,11 @@ enum AccessorKind {
public InterfaceEventImplementedByNode(EventDef analyzedEvent) {
this.analyzedEvent = analyzedEvent ?? throw new ArgumentNullException(nameof(analyzedEvent));
- if (!(this.analyzedEvent.AddMethod is null)) {
+ if (this.analyzedEvent.AddMethod is not null) {
analyzedMethod = this.analyzedEvent.AddMethod;
accessorKind = AccessorKind.Adder;
}
- else if (!(this.analyzedEvent.RemoveMethod is null)) {
+ else if (this.analyzedEvent.RemoveMethod is not null) {
analyzedMethod = this.analyzedEvent.RemoveMethod;
accessorKind = AccessorKind.Remover;
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceMethodImplementedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceMethodImplementedByNode.cs
index 1dafb04959..f255c157e8 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceMethodImplementedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/InterfaceMethodImplementedByNode.cs
@@ -65,7 +65,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(comIface is null) && ComUtils.GetMethod(comIface, vtblIndex) is MethodDef comIfaceMethod) {
+ if (comIface is not null && ComUtils.GetMethod(comIface, vtblIndex) is MethodDef comIfaceMethod) {
foreach (var method in type.Methods) {
// Don't include abstract methods, they don't implement anything
if (!method.IsVirtual || method.IsAbstract)
@@ -77,7 +77,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(implementedInterfaceRef is null)) {
+ if (implementedInterfaceRef is not null) {
foreach (var method in type.Methods) {
// Don't include abstract methods, they don't implement anything
if (!method.IsVirtual || method.IsAbstract)
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/InterfacePropertyImplementedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/InterfacePropertyImplementedByNode.cs
index a8ec8e873b..094896287a 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/InterfacePropertyImplementedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/InterfacePropertyImplementedByNode.cs
@@ -33,7 +33,7 @@ sealed class InterfacePropertyImplementedByNode : SearchNode {
public InterfacePropertyImplementedByNode(PropertyDef analyzedProperty) {
this.analyzedProperty = analyzedProperty ?? throw new ArgumentNullException(nameof(analyzedProperty));
- if (!(this.analyzedProperty.GetMethod is null)) {
+ if (this.analyzedProperty.GetMethod is not null) {
analyzedMethod = this.analyzedProperty.GetMethod;
isGetter = true;
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/MethodOverriddenNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/MethodOverriddenNode.cs
index e8dc9e0723..c833dbfc4c 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/MethodOverriddenNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/MethodOverriddenNode.cs
@@ -66,7 +66,7 @@ protected override IEnumerable FetchChildren(CancellationT
}
public static bool CanShow(MethodDef method) =>
- !(method.DeclaringType.BaseType is null) &&
+ method.DeclaringType.BaseType is not null &&
(method.IsVirtual || method.IsAbstract) && method.IsReuseSlot;
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsedByNode.cs
index 036b3799bb..03a16ba401 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsedByNode.cs
@@ -81,18 +81,18 @@ protected override IEnumerable FetchChildren(CancellationT
if (isSetter)
property = analyzedMethod.DeclaringType.Properties.FirstOrDefault(a => a.SetMethod == analyzedMethod);
- var includeAllModules = (!(property is null) && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedMethod.DeclaringType)) || !(implMapName is null);
+ var includeAllModules = (property is not null && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedMethod.DeclaringType)) || implMapName is not null;
var options = ScopedWhereUsedAnalyzerOptions.None;
if (includeAllModules)
options |= ScopedWhereUsedAnalyzerOptions.IncludeAllModules;
- if (!(implMapName is null))
+ if (implMapName is not null)
options |= ScopedWhereUsedAnalyzerOptions.ForcePublic;
var analyzer = new ScopedWhereUsedAnalyzer(Context.DocumentService, analyzedMethod, FindReferencesInType, options);
foreach (var child in analyzer.PerformAnalysis(ct)) {
yield return child;
}
- if (!(property is null)) {
+ if (property is not null) {
var hash = new HashSet();
foreach (var module in analyzer.AllModules) {
if (module.Assembly is AssemblyDef asm && hash.Add(asm)) {
@@ -113,7 +113,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
if (!method.HasBody)
continue;
Instruction? foundInstr = null;
- if (!(implMapName is null)) {
+ if (implMapName is not null) {
foreach (var instr in method.Body.Instructions) {
if (instr.Operand is IMethod mr && !mr.IsField &&
mr.ResolveMethodDef() is MethodDef md &&
@@ -137,7 +137,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(foundInstr is null)) {
+ if (foundInstr is not null) {
if (GetOriginalCodeLocation(method) is MethodDef codeLocation && !HasAlreadyBeenFound(codeLocation)) {
var node = new MethodNode(codeLocation) { Context = Context };
if (codeLocation == method)
@@ -147,7 +147,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(property is null)) {
+ if (property is not null) {
foreach (var node in FieldAccessNode.CheckCustomAttributeNamedArgumentWrite(Context, type, property)) {
if (node is MethodNode methodNode && methodNode.Member is MethodDef method && HasAlreadyBeenFound(method))
continue;
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsesNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsesNode.cs
index a5a16b5779..840061f300 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsesNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/MethodUsesNode.cs
@@ -60,7 +60,7 @@ IEnumerable> GetUsedMethods() {
foreach (Instruction instr in analyzedMethod.Body.Instructions) {
if (instr.Operand is IMethod mr && !mr.IsField) {
MethodDef def = mr.ResolveMethodDef();
- if (!(def is null))
+ if (def is not null)
yield return new DefRef(def, new SourceRef(analyzedMethod, instr.Offset, instr.Operand as IMDTokenProvider));
}
}
@@ -70,7 +70,7 @@ IEnumerable> GetUsedFields() {
foreach (Instruction instr in analyzedMethod.Body.Instructions) {
if (instr.Operand is IField fr && !fr.IsMethod) {
FieldDef def = fr.ResolveFieldDef();
- if (!(def is null))
+ if (def is not null)
yield return new DefRef(def, new SourceRef(analyzedMethod, instr.Offset, instr.Operand as IMDTokenProvider));
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyAccessorNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyAccessorNode.cs
index bb8aa15fb4..5f7146669d 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyAccessorNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyAccessorNode.cs
@@ -28,7 +28,7 @@ public PropertyAccessorNode(MethodDef analyzedMethod, string? name, bool isSette
: base(analyzedMethod, isSetter: isSetter) => this.name = name;
protected override void Write(ITextColorWriter output, IDecompiler decompiler) {
- if (!(name is null))
+ if (name is not null)
output.Write(BoxedTextColor.Keyword, name);
else
base.Write(output, decompiler);
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyNode.cs
index f1ff8bae20..380d693210 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyNode.cs
@@ -56,10 +56,10 @@ protected override void Write(ITextColorWriter output, IDecompiler decompiler) {
}
public override IEnumerable CreateChildren() {
- if (!(analyzedProperty.GetMethod is null))
+ if (analyzedProperty.GetMethod is not null)
yield return new PropertyAccessorNode(analyzedProperty.GetMethod, "get", isSetter: false);
- if (!(analyzedProperty.SetMethod is null))
+ if (analyzedProperty.SetMethod is not null)
yield return new PropertyAccessorNode(analyzedProperty.SetMethod, "set", isSetter: true);
foreach (var accessor in analyzedProperty.OtherMethods)
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverriddenNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverriddenNode.cs
index 28c7efd518..ff1d227ddb 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverriddenNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverriddenNode.cs
@@ -68,18 +68,18 @@ protected override IEnumerable FetchChildren(CancellationT
}
public static bool CanShow(PropertyDef property) =>
- !((GetAccessor(property.GetMethod) ?? GetAccessor(property.SetMethod)) is null);
+ (GetAccessor(property.GetMethod) ?? GetAccessor(property.SetMethod)) is not null;
static MethodDef? GetAccessor(MethodDef? accessor) {
- if (!(accessor is null) &&
- !(accessor.DeclaringType.BaseType is null) &&
+ if (accessor is not null &&
+ accessor.DeclaringType.BaseType is not null &&
(accessor.IsVirtual || accessor.IsAbstract) && accessor.IsReuseSlot)
return accessor;
return null;
}
static MethodDef? GetVirtualAccessor(MethodDef? accessor) {
- if (!(accessor is null) && (accessor.IsVirtual || accessor.IsAbstract))
+ if (accessor is not null && (accessor.IsVirtual || accessor.IsAbstract))
return accessor;
return null;
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverridesNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverridesNode.cs
index f6ad1791b5..f2593ebbd7 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverridesNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/PropertyOverridesNode.cs
@@ -56,7 +56,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
public static bool CanShow(PropertyDef property) {
var accessor = property.GetMethod ?? property.SetMethod;
- return !(accessor is null) && accessor.IsVirtual && !accessor.IsFinal && !accessor.DeclaringType.IsInterface;
+ return accessor is not null && accessor.IsVirtual && !accessor.IsFinal && !accessor.DeclaringType.IsInterface;
}
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/ScopedWhereUsedAnalyzer.cs b/Extensions/dnSpy.Analyzer/TreeNodes/ScopedWhereUsedAnalyzer.cs
index 8961b841fb..99ec90b5b6 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/ScopedWhereUsedAnalyzer.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/ScopedWhereUsedAnalyzer.cs
@@ -297,7 +297,7 @@ IEnumerable GetReferencingModules(ModuleDef mod, CancellationToken ct
var modules = documentService.GetDocuments().Where(a => SearchNode.CanIncludeModule(mod, a.ModuleDef));
foreach (var module in modules) {
- Debug2.Assert(!(module.ModuleDef is null));
+ Debug2.Assert(module.ModuleDef is not null);
ct.ThrowIfCancellationRequested();
if (ModuleReferencesScopeType(module.ModuleDef))
yield return module.ModuleDef;
@@ -316,7 +316,7 @@ IEnumerable GetModuleAndAnyFriends(ModuleDef mod, CancellationToken c
var friendAssemblies = SearchNode.GetFriendAssemblies(documentService, mod, out var modules);
if (friendAssemblies.Count > 0) {
foreach (var module in modules) {
- Debug2.Assert(!(module.ModuleDef is null));
+ Debug2.Assert(module.ModuleDef is not null);
ct.ThrowIfCancellationRequested();
if ((module.AssemblyDef is null || friendAssemblies.Contains(module.AssemblyDef.Name)) && ModuleReferencesScopeType(module.ModuleDef))
yield return module.ModuleDef;
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/SearchNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/SearchNode.cs
index 46fe40e782..279b7a0ec5 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/SearchNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/SearchNode.cs
@@ -48,14 +48,14 @@ public override IEnumerable CreateChildren() {
internal IEnumerable FetchChildrenInternal(CancellationToken token) => FetchChildren(token);
public override void OnIsVisibleChanged() {
- if (!TreeNode.IsVisible && !(asyncFetchChildrenHelper is null) && !asyncFetchChildrenHelper.CompletedSuccessfully) {
+ if (!TreeNode.IsVisible && asyncFetchChildrenHelper is not null && !asyncFetchChildrenHelper.CompletedSuccessfully) {
CancelAndClearChildren();
TreeNode.LazyLoading = true;
}
}
public override void OnIsExpandedChanged(bool isExpanded) {
- if (!isExpanded && !(asyncFetchChildrenHelper is null) && !asyncFetchChildrenHelper.CompletedSuccessfully) {
+ if (!isExpanded && asyncFetchChildrenHelper is not null && !asyncFetchChildrenHelper.CompletedSuccessfully) {
CancelAndClearChildren();
TreeNode.LazyLoading = true;
}
@@ -95,14 +95,14 @@ internal static bool CanIncludeModule(ModuleDef targetModule, ModuleDef? module)
return false;
if (targetModule == module)
return false;
- if (!(targetModule.Assembly is null) && targetModule.Assembly == module.Assembly)
+ if (targetModule.Assembly is not null && targetModule.Assembly == module.Assembly)
return false;
return true;
}
internal static HashSet GetFriendAssemblies(IDsDocumentService documentService, ModuleDef mod, out IDsDocument[] modules) {
var asm = mod.Assembly;
- Debug2.Assert(!(asm is null));
+ Debug2.Assert(asm is not null);
var friendAssemblies = new HashSet(StringComparer.OrdinalIgnoreCase);
foreach (var attribute in asm.CustomAttributes.FindAll("System.Runtime.CompilerServices.InternalsVisibleToAttribute")) {
if (attribute.ConstructorArguments.Count == 0)
@@ -115,7 +115,7 @@ internal static HashSet GetFriendAssemblies(IDsDocumentService documentS
}
modules = documentService.GetDocuments().Where(a => CanIncludeModule(mod, a.ModuleDef)).ToArray();
foreach (var module in modules) {
- Debug2.Assert(!(module.ModuleDef is null));
+ Debug2.Assert(module.ModuleDef is not null);
var asm2 = module.AssemblyDef;
if (asm2 is null)
continue;
@@ -135,7 +135,7 @@ internal static void AddTypeEquivalentTypes(IDsDocumentService documentService,
Debug.Assert(analyzedTypes.Count == 1 && analyzedTypes[0] == analyzedType);
if (!TIAHelper.IsTypeDefEquivalent(analyzedType))
return;
- foreach (var document in documentService.GetDocuments().Where(a => !(a.ModuleDef is null))) {
+ foreach (var document in documentService.GetDocuments().Where(a => a.ModuleDef is not null)) {
foreach (var type in GetTypeEquivalentTypes(document.AssemblyDef, document.ModuleDef, analyzedType)) {
if (type != analyzedType)
analyzedTypes.Add(type);
@@ -157,12 +157,12 @@ static IEnumerable GetTypeEquivalentTypes(AssemblyDef? assembly, Module
}
static IEnumerable GetModules(AssemblyDef? assembly, ModuleDef? module) {
- if (!(assembly is null)) {
+ if (assembly is not null) {
foreach (var mod in assembly.Modules)
yield return mod;
}
else {
- if (!(module is null))
+ if (module is not null)
yield return module;
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/TypeExposedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/TypeExposedByNode.cs
index 7331a9c23b..57059184e2 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/TypeExposedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/TypeExposedByNode.cs
@@ -186,7 +186,7 @@ bool TypeIsExposedBy(MethodDef method) {
return false;
var methDecl = method.Overrides[0].MethodDeclaration;
var typeDef = methDecl?.DeclaringType?.ResolveTypeDef();
- if (!(typeDef is null) && !typeDef.IsInterface)
+ if (typeDef is not null && !typeDef.IsInterface)
return false;
}
@@ -216,15 +216,15 @@ bool TypeIsExposedBy(MethodBaseSig? methodSig, int recursionCounter) {
}
static bool IsPrivate(PropertyDef property) {
- bool isGetterPublic = (!(property.GetMethod is null) && !property.GetMethod.IsPrivate);
- bool isSetterPublic = (!(property.SetMethod is null) && !property.SetMethod.IsPrivate);
+ bool isGetterPublic = (property.GetMethod is not null && !property.GetMethod.IsPrivate);
+ bool isSetterPublic = (property.SetMethod is not null && !property.SetMethod.IsPrivate);
return !(isGetterPublic || isSetterPublic);
}
static bool IsPrivate(EventDef eventDef) {
- bool isAdderPublic = (!(eventDef.AddMethod is null) && !eventDef.AddMethod.IsPrivate);
- bool isRemoverPublic = (!(eventDef.RemoveMethod is null) && !eventDef.RemoveMethod.IsPrivate);
- bool isInvokerPublic = (!(eventDef.InvokeMethod is null) && !eventDef.InvokeMethod.IsPrivate);
+ bool isAdderPublic = (eventDef.AddMethod is not null && !eventDef.AddMethod.IsPrivate);
+ bool isRemoverPublic = (eventDef.RemoveMethod is not null && !eventDef.RemoveMethod.IsPrivate);
+ bool isInvokerPublic = (eventDef.InvokeMethod is not null && !eventDef.InvokeMethod.IsPrivate);
return !(isAdderPublic || isRemoverPublic || isInvokerPublic);
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/TypeExtensionMethodsNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/TypeExtensionMethodsNode.cs
index aabf7ff71d..0778945009 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/TypeExtensionMethodsNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/TypeExtensionMethodsNode.cs
@@ -73,7 +73,7 @@ static int GetParametersSkip(IList parameters) {
return 0;
}
- bool HasExtensionAttribute(IHasCustomAttribute p) => !(p.CustomAttributes.Find("System.Runtime.CompilerServices.ExtensionAttribute") is null);
+ bool HasExtensionAttribute(IHasCustomAttribute p) => p.CustomAttributes.Find("System.Runtime.CompilerServices.ExtensionAttribute") is not null;
// show on all types except static classes
public static bool CanShow(TypeDef type) => !(type.IsAbstract && type.IsSealed);
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/TypeInstantiationsNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/TypeInstantiationsNode.cs
index 27a6cbe9f2..f43fb2b8ae 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/TypeInstantiationsNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/TypeInstantiationsNode.cs
@@ -64,7 +64,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(foundInstr is null))
+ if (foundInstr is not null)
yield return new MethodNode(method) { Context = Context, SourceRef = new SourceRef(method, foundInstr.Offset, foundInstr.Operand as IMDTokenProvider) };
}
}
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/TypeUsedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/TypeUsedByNode.cs
index 881b696920..4bb5b0ce61 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/TypeUsedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/TypeUsedByNode.cs
@@ -90,7 +90,7 @@ IEnumerable FindTypeUsage(TypeDef? type) {
if (new SigComparer().Equals(type, analyzedType))
yield break;
if (isComType && ComUtils.ComEquals(type, ref comGuid)) {
- Debug2.Assert(!(allTypes is null));
+ Debug2.Assert(allTypes is not null);
lock (allTypes)
allTypes.Add(type);
yield break;
@@ -121,11 +121,11 @@ IEnumerable FindTypeUsage(TypeDef? type) {
EntityNode HandleSpecialMethodNode(MethodDef method, SourceRef? sourceRef) {
var property = method.DeclaringType.Properties.FirstOrDefault(p => (object?)p.GetMethod == method || (object?)p.SetMethod == method);
- if (!(property is null))
+ if (property is not null)
return new PropertyNode(property) { Context = Context, SourceRef = sourceRef };
var @event = method.DeclaringType.Events.FirstOrDefault(p => (object?)p.AddMethod == method || (object?)p.RemoveMethod == method || (object?)p.InvokeMethod == method);
- if (!(@event is null))
+ if (@event is not null)
return new EventNode(@event) { Context = Context, SourceRef = sourceRef };
return new MethodNode(method) { Context = Context, SourceRef = sourceRef };
@@ -284,7 +284,7 @@ bool TypeMatches(IType? tref, int level) {
return false;
if (isComType && tref.Resolve() is TypeDef td && ComUtils.ComEquals(td, ref comGuid))
return true;
- if (!(tref is null)) {
+ if (tref is not null) {
if (new SigComparer().Equals(analyzedType, tref.GetScopeType()))
return true;
if (tref is TypeSig ts) {
@@ -301,7 +301,7 @@ bool TypeMatches(IType? tref, int level) {
if (TypeMatches(p, level + 1))
return true;
}
- if (!(msig.ParamsAfterSentinel is null)) {
+ if (msig.ParamsAfterSentinel is not null) {
foreach (var p in msig.ParamsAfterSentinel) {
if (TypeMatches(p, level + 1))
return true;
@@ -349,7 +349,7 @@ bool TypeMatches(IType? tref, int level) {
return false;
}
- public static bool CanShow(TypeDef? type) => !(type is null);
+ public static bool CanShow(TypeDef? type) => type is not null;
}
sealed class AnalyzerEntityTreeNodeComparer : IEqualityComparer {
diff --git a/Extensions/dnSpy.Analyzer/TreeNodes/VirtualMethodUsedByNode.cs b/Extensions/dnSpy.Analyzer/TreeNodes/VirtualMethodUsedByNode.cs
index 1107e92a86..e3ff623747 100644
--- a/Extensions/dnSpy.Analyzer/TreeNodes/VirtualMethodUsedByNode.cs
+++ b/Extensions/dnSpy.Analyzer/TreeNodes/VirtualMethodUsedByNode.cs
@@ -52,7 +52,7 @@ protected override IEnumerable FetchChildren(CancellationT
if (isSetter)
property = analyzedMethod.DeclaringType.Properties.FirstOrDefault(a => a.SetMethod == analyzedMethod);
- var includeAllModules = !(property is null) && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedMethod.DeclaringType);
+ var includeAllModules = property is not null && CustomAttributesUtils.IsPseudoCustomAttributeType(analyzedMethod.DeclaringType);
ComUtils.GetMemberInfo(analyzedMethod, out isComType, out comGuid, out vtblIndex);
includeAllModules |= isComType;
var options = ScopedWhereUsedAnalyzerOptions.None;
@@ -65,7 +65,7 @@ protected override IEnumerable FetchChildren(CancellationT
yield return child;
}
- if (!(property is null)) {
+ if (property is not null) {
var hash = new HashSet();
foreach (var module in analyzer.AllModules) {
if (module.Assembly is AssemblyDef asm && hash.Add(module.Assembly)) {
@@ -109,7 +109,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
if (isComType) {
md ??= mr.ResolveMethodDef();
- if (!(md is null)) {
+ if (md is not null) {
ComUtils.GetMemberInfo(md, out bool otherIsComType, out var otherComGuid, out int otherVtblIndex);
if (otherIsComType && comGuid == otherComGuid && vtblIndex == otherVtblIndex) {
foundInstr = instr;
@@ -140,7 +140,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(foundInstr is null)) {
+ if (foundInstr is not null) {
if (GetOriginalCodeLocation(method) is MethodDef codeLocation && !HasAlreadyBeenFound(codeLocation)) {
var node = new MethodNode(codeLocation) { Context = Context };
if (codeLocation == method)
@@ -150,7 +150,7 @@ IEnumerable FindReferencesInType(TypeDef type) {
}
}
- if (!(property is null)) {
+ if (property is not null) {
foreach (var node in FieldAccessNode.CheckCustomAttributeNamedArgumentWrite(Context, type, property)) {
if (node is MethodNode methodNode && methodNode.Member is MethodDef method && HasAlreadyBeenFound(method))
continue;
diff --git a/Extensions/dnSpy.Analyzer/TreeTraversal.cs b/Extensions/dnSpy.Analyzer/TreeTraversal.cs
index b9d1ef238c..ea8bf0748a 100644
--- a/Extensions/dnSpy.Analyzer/TreeTraversal.cs
+++ b/Extensions/dnSpy.Analyzer/TreeTraversal.cs
@@ -47,7 +47,7 @@ public static IEnumerable PreOrder(IEnumerable input, Func children = recursion(element);
- if (!(children is null)) {
+ if (children is not null) {
stack.Push(children.GetEnumerator());
}
}
@@ -83,7 +83,7 @@ public static IEnumerable PostOrder(IEnumerable input, Func children = recursion(element);
- if (!(children is null)) {
+ if (children is not null) {
stack.Push(children.GetEnumerator());
}
else {
diff --git a/Extensions/dnSpy.AsmEditor/Assembly/AssemblyCommands.cs b/Extensions/dnSpy.AsmEditor/Assembly/AssemblyCommands.cs
index 5ed73d3701..811e37ada0 100644
--- a/Extensions/dnSpy.AsmEditor/Assembly/AssemblyCommands.cs
+++ b/Extensions/dnSpy.AsmEditor/Assembly/AssemblyCommands.cs
@@ -52,7 +52,7 @@ sealed class CommandLoader : IAutoLoaded {
sealed class DisableMemoryMappedIOCommand : MenuItemBase {
public override bool IsVisible(IMenuItemContext context) =>
context.CreatorObject.Guid == new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID) &&
- (context.Find() ?? Array.Empty()).Any(a => !(GetDocument(a) is null));
+ (context.Find() ?? Array.Empty()).Any(a => GetDocument(a) is not null);
static IDsDocument? GetDocument(TreeNodeData node) {
var fileNode = node as DsDocumentNode;
@@ -72,7 +72,7 @@ public override void Execute(IMenuItemContext context) {
var asms = new List();
foreach (var node in (context.Find() ?? Array.Empty())) {
var file = GetDocument(node);
- if (!(file is null))
+ if (file is not null)
asms.Add(file);
}
foreach (var asm in asms)
@@ -276,7 +276,7 @@ internal sealed class EditMenuCommand : EditMenuHandler {
}
static bool CanExecute(DocumentTreeNodeData[] nodes) =>
- !(nodes is null) &&
+ nodes is not null &&
nodes.Length == 1 &&
nodes[0] is AssemblyDocumentNode;
@@ -327,7 +327,7 @@ public AssemblyRefInfo(AssemblyRef asmRef) {
public void Execute() {
newOptions.CopyTo(asmNode.Document.AssemblyDef!);
- if (!(assemblyRefInfos is null)) {
+ if (assemblyRefInfos is not null) {
var pkt = newOptions.PublicKey.Token;
foreach (var info in assemblyRefInfos) {
info.AssemblyRef.Name = newOptions.Name;
@@ -343,7 +343,7 @@ public void Execute() {
public void Undo() {
origOptions.CopyTo(asmNode.Document.AssemblyDef!);
- if (!(assemblyRefInfos is null)) {
+ if (assemblyRefInfos is not null) {
foreach (var info in assemblyRefInfos) {
info.AssemblyRef.Name = info.OrigName;
info.AssemblyRef.PublicKeyOrToken = info.OrigPublicKeyOrToken;
@@ -392,7 +392,7 @@ sealed class EditMenuCommand : EditMenuHandler {
}
static bool CanExecute(DocumentTreeNodeData[] nodes) =>
- !(nodes is null) &&
+ nodes is not null &&
(nodes.Length == 0 || nodes[0] is DsDocumentNode);
static void Execute(Lazy undoCommandService, IAppService appService, DocumentTreeNodeData[] nodes) {
diff --git a/Extensions/dnSpy.AsmEditor/Commands/CloseAllMissingFilesCommand.cs b/Extensions/dnSpy.AsmEditor/Commands/CloseAllMissingFilesCommand.cs
index e5b58e40af..95f519e4db 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/CloseAllMissingFilesCommand.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/CloseAllMissingFilesCommand.cs
@@ -47,10 +47,10 @@ sealed class CloseAllMissingFilesCommand : MenuItemBase {
return nodes.Length == 0 ? null : nodes;
}
- public override bool IsEnabled(IMenuItemContext context) => !(GetNodes() is null);
+ public override bool IsEnabled(IMenuItemContext context) => GetNodes() is not null;
public override void Execute(IMenuItemContext context) {
var nodes = GetNodes();
- if (!(nodes is null))
+ if (nodes is not null)
RemoveAssemblyCommand.Execute(undoCommandService, documentSaver, appService, nodes);
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/CloseOldInMemoryModulesCommand.cs b/Extensions/dnSpy.AsmEditor/Commands/CloseOldInMemoryModulesCommand.cs
index 7782bce943..a789345c8e 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/CloseOldInMemoryModulesCommand.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/CloseOldInMemoryModulesCommand.cs
@@ -54,10 +54,10 @@ sealed class CloseOldInMemoryModulesCommand : MenuItemBase {
return nodes.Count == 0 ? null : nodes.ToArray();
}
- public override bool IsEnabled(IMenuItemContext context) => !(GetNodes() is null);
+ public override bool IsEnabled(IMenuItemContext context) => GetNodes() is not null;
public override void Execute(IMenuItemContext context) {
var nodes = GetNodes();
- if (!(nodes is null))
+ if (nodes is not null)
RemoveAssemblyCommand.Execute(undoCommandService, documentSaver, appService, nodes);
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/CodeContextMenuHandlerCommandProxy.cs b/Extensions/dnSpy.AsmEditor/Commands/CodeContextMenuHandlerCommandProxy.cs
index 62b014abe6..ae8a9d7237 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/CodeContextMenuHandlerCommandProxy.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/CodeContextMenuHandlerCommandProxy.cs
@@ -56,13 +56,13 @@ event EventHandler? ICommand.CanExecuteChanged {
bool ICommand.CanExecute(object? parameter) {
var ctx = CreateContext();
- return !(ctx is null) && command.IsVisible(ctx) && command.IsEnabled(ctx);
+ return ctx is not null && command.IsVisible(ctx) && command.IsEnabled(ctx);
}
void ICommand.Execute(object? parameter) {
var ctx = CreateContext();
- Debug2.Assert(!(ctx is null));
- if (!(ctx is null))
+ Debug2.Assert(ctx is not null);
+ if (ctx is not null)
command.Execute(ctx);
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/CommandUtils.cs b/Extensions/dnSpy.AsmEditor/Commands/CommandUtils.cs
index e91d7e6ec2..1f995081e4 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/CommandUtils.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/CommandUtils.cs
@@ -38,11 +38,11 @@ public static void AddRemoveCommand(this IWpfCommandService wpfCommandService, C
}
public static void AddSettingsCommand(this IWpfCommandService wpfCommandService, IDocumentTabService documentTabService, EditMenuHandler? treeViewCmd, CodeContextMenuHandler? textEditorCmd) {
- if (!(treeViewCmd is null)) {
+ if (treeViewCmd is not null) {
var cmds = wpfCommandService.GetCommands(ControlConstants.GUID_DOCUMENT_TREEVIEW);
cmds.Add(SettingsRoutedCommand, new EditMenuHandlerCommandProxy(treeViewCmd));
}
- if (!(textEditorCmd is null)) {
+ if (textEditorCmd is not null) {
var cmds = wpfCommandService.GetCommands(ControlConstants.GUID_DOCUMENTVIEWER_UICONTEXT);
cmds.Add(SettingsRoutedCommand, new CodeContextMenuHandlerCommandProxy(textEditorCmd, documentTabService), ModifierKeys.Alt, Key.Enter);
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/DeletableNodes.cs b/Extensions/dnSpy.AsmEditor/Commands/DeletableNodes.cs
index 27127f85c3..c0b18b44ec 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/DeletableNodes.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/DeletableNodes.cs
@@ -47,7 +47,7 @@ public DeletableNodes(IEnumerable nodes) {
///
public void Delete() {
Debug2.Assert(parents is null);
- if (!(parents is null))
+ if (parents is not null)
throw new ArgumentException("Nodes have already been deleted");
parents = new DocumentTreeNodeData[nodes.Length];
@@ -65,7 +65,7 @@ public void Delete() {
/// The model (dnlib) elements must be restored before this method is called, not after.
///
public void Restore() {
- Debug2.Assert(!(parents is null));
+ Debug2.Assert(parents is not null);
if (parents is null)
throw new ArgumentException("Nodes have already been restored");
diff --git a/Extensions/dnSpy.AsmEditor/Commands/DeletedTypeUpdater.cs b/Extensions/dnSpy.AsmEditor/Commands/DeletedTypeUpdater.cs
index 12bc332fac..d82d56d074 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/DeletedTypeUpdater.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/DeletedTypeUpdater.cs
@@ -50,7 +50,7 @@ public DeletedTypeUpdater(ModuleDocumentNode modNode, TypeDef originalType) {
public void Add() {
if (!parentNode.TreeNode.Children.Remove(ownerNode.TreeNode))
throw new InvalidOperationException();
- if (!(ownerType is null)) {
+ if (ownerType is not null) {
typeIndex = ownerType.NestedTypes.IndexOf(type);
ownerType.NestedTypes.RemoveAt(typeIndex);
}
@@ -61,7 +61,7 @@ public void Add() {
}
public void Remove() {
- if (!(ownerType is null))
+ if (ownerType is not null)
ownerType.NestedTypes.Insert(typeIndex, type);
else
ownerModule.Types.Insert(typeIndex, type);
diff --git a/Extensions/dnSpy.AsmEditor/Commands/DocumentsContextMenuHandler.cs b/Extensions/dnSpy.AsmEditor/Commands/DocumentsContextMenuHandler.cs
index 481c4cc6dc..63a31762de 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/DocumentsContextMenuHandler.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/DocumentsContextMenuHandler.cs
@@ -33,7 +33,7 @@ abstract class DocumentsContextMenuHandler : MenuItemBase {
if (context.CreatorObject.Guid != new Guid(MenuConstants.GUIDOBJ_DOCUMENTS_TREEVIEW_GUID))
return null;
var ary = context.Find();
- Debug2.Assert(!(ary is null));
+ Debug2.Assert(ary is not null);
return new AsmEditorContext(ary is null ? Array.Empty() : ary.OfType().ToArray());
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/EditMenuHandlerCommandProxy.cs b/Extensions/dnSpy.AsmEditor/Commands/EditMenuHandlerCommandProxy.cs
index e34e06a4cc..a98c18d644 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/EditMenuHandlerCommandProxy.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/EditMenuHandlerCommandProxy.cs
@@ -36,13 +36,13 @@ event EventHandler? ICommand.CanExecuteChanged {
bool ICommand.CanExecute(object? parameter) {
var ctx = CreateContext();
- return !(ctx is null) && command.IsVisible(ctx) && command.IsEnabled(ctx);
+ return ctx is not null && command.IsVisible(ctx) && command.IsEnabled(ctx);
}
void ICommand.Execute(object? parameter) {
var ctx = CreateContext();
- Debug2.Assert(!(ctx is null));
- if (!(ctx is null))
+ Debug2.Assert(ctx is not null);
+ if (ctx is not null)
command.Execute(ctx);
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/EventNodeCreator.cs b/Extensions/dnSpy.AsmEditor/Commands/EventNodeCreator.cs
index b7ff79b7e2..2193a4a1d2 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/EventNodeCreator.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/EventNodeCreator.cs
@@ -38,11 +38,11 @@ public EventNodeCreator(ModuleDocumentNode modNode, TypeNode ownerNode, EventDef
}
IEnumerable GetMethods() {
- if (!(eventNode.EventDef.AddMethod is null))
+ if (eventNode.EventDef.AddMethod is not null)
yield return eventNode.EventDef.AddMethod;
- if (!(eventNode.EventDef.RemoveMethod is null))
+ if (eventNode.EventDef.RemoveMethod is not null)
yield return eventNode.EventDef.RemoveMethod;
- if (!(eventNode.EventDef.InvokeMethod is null))
+ if (eventNode.EventDef.InvokeMethod is not null)
yield return eventNode.EventDef.InvokeMethod;
foreach (var m in eventNode.EventDef.OtherMethods)
yield return m;
diff --git a/Extensions/dnSpy.AsmEditor/Commands/IndexObservableCollection.cs b/Extensions/dnSpy.AsmEditor/Commands/IndexObservableCollection.cs
index 6754edbf95..44b4621234 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/IndexObservableCollection.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/IndexObservableCollection.cs
@@ -35,7 +35,7 @@ class IndexObservableCollection : ObservableCollection where T : class, II
public ICommand RemoveAllItemsCommand => new RelayCommand(a => RemoveAllItems((T[])a!), a => RemoveAllItemsCanExecute((T[])a!));
public bool DisableAutoUpdateProps { get; set; }
public Action? UpdateIndexesDelegate { get; set; }
- public bool CanCreateNewItems => !(createNewItem is null);
+ public bool CanCreateNewItems => createNewItem is not null;
public bool CanRemoveItems => true;
public bool CanMoveItems => true;
@@ -91,7 +91,7 @@ protected override void RemoveItem(int index) {
}
public void UpdateIndexes(int index) {
- if (!(UpdateIndexesDelegate is null))
+ if (UpdateIndexesDelegate is not null)
UpdateIndexesDelegate(index);
else
DefaultUpdateIndexes(index);
diff --git a/Extensions/dnSpy.AsmEditor/Commands/InstructionCommands.cs b/Extensions/dnSpy.AsmEditor/Commands/InstructionCommands.cs
index 370b3b2f7c..5c4d9f7c38 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/InstructionCommands.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/InstructionCommands.cs
@@ -80,12 +80,12 @@ public override void Execute(IMenuItemContext context) {
}
public static bool CanExecute(IDocumentViewer? documentViewer) =>
- !(documentViewer is null) && FindInstructions(documentViewer).Any();
+ documentViewer is not null && FindInstructions(documentViewer).Any();
public static void Execute(IDocumentViewer? documentViewer, Lazy methodAnnotations) {
if (!CanExecute(documentViewer))
return;
- Debug2.Assert(!(documentViewer is null));
+ Debug2.Assert(documentViewer is not null);
var copier = new InstructionILBytesCopier();
var text = copier.Copy(FindInstructions(documentViewer), methodAnnotations);
diff --git a/Extensions/dnSpy.AsmEditor/Commands/ListBoxHelperBase.cs b/Extensions/dnSpy.AsmEditor/Commands/ListBoxHelperBase.cs
index f64fbf3af4..75b20782d0 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/ListBoxHelperBase.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/ListBoxHelperBase.cs
@@ -212,7 +212,7 @@ protected void AddCopyHandlers() {
}
public void OnDataContextChanged(object dataContext) {
- if (!(coll is null))
+ if (coll is not null)
throw new InvalidOperationException("DataContext changed more than once");
// Can't add M, N etc as shortcuts so must use a key down handler
@@ -281,9 +281,9 @@ static void ShowContextMenu(ContextMenuEventArgs e, ListBox listBox, IList 1 ? handler.HeaderPlural ?? handler.Header : handler.Header);
var tmpHandler = handler;
menuItem.Click += (s, e2) => tmpHandler.Command.Execute(parameter);
- if (!(handler.Icon is null))
+ if (handler.Icon is not null)
Add16x16Image(menuItem, handler.Icon.Value, menuItem.IsEnabled);
- if (!(handler.InputGestureText is null))
+ if (handler.InputGestureText is not null)
menuItem.InputGestureText = ResourceHelper.GetString(handler, handler.InputGestureText);
if (addSep) {
@@ -362,8 +362,8 @@ void PasteItems(int relIndex) {
}
void PasteItems() => PasteItems(0);
- bool PasteItemsCanExecute() => !(GetClipboardData() is null);
+ bool PasteItemsCanExecute() => GetClipboardData() is not null;
void PasteAfterItems() => PasteItems(1);
- bool PasteAfterItemsCanExecute() => listBox.SelectedIndex >= 0 && !(GetClipboardData() is null);
+ bool PasteAfterItemsCanExecute() => listBox.SelectedIndex >= 0 && GetClipboardData() is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Commands/NestedTypeNodeCreator.cs b/Extensions/dnSpy.AsmEditor/Commands/NestedTypeNodeCreator.cs
index 0308f3ca6b..793b7a2174 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/NestedTypeNodeCreator.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/NestedTypeNodeCreator.cs
@@ -34,7 +34,7 @@ sealed class NestedTypeNodeCreator {
public IEnumerable OriginalNodes {
get {
yield return ownerTypeNode;
- if (!(nestedTypeNode is null))
+ if (nestedTypeNode is not null)
yield return nestedTypeNode;
}
}
@@ -44,7 +44,7 @@ public NestedTypeNodeCreator(ModuleDocumentNode modNode, TypeNode ownerTypeNode,
throw new ArgumentNullException(nameof(modNode));
if (nestedType is null)
throw new ArgumentNullException(nameof(nestedType));
- if (!(nestedType.Module is null))
+ if (nestedType.Module is not null)
throw new ArgumentException();
this.ownerTypeNode = ownerTypeNode;
nestedTypeNode = modNode.Context.DocumentTreeView.CreateNested(nestedType);
diff --git a/Extensions/dnSpy.AsmEditor/Commands/RefFinder.cs b/Extensions/dnSpy.AsmEditor/Commands/RefFinder.cs
index f712d38133..3eca73bfa1 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/RefFinder.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/RefFinder.cs
@@ -95,7 +95,7 @@ static bool Equals(IMemberRefParent @class, TypeDef type) {
var tdrSig = typeSig as TypeDefOrRefSig;
if (tdrSig is null && typeSig is GenericInstSig gis)
tdrSig = gis.GenericType;
- if (!(tdrSig is null)) {
+ if (tdrSig is not null) {
if (tdrSig.TypeDefOrRef is TypeDef td2)
return TypeEqualityComparerInstance.Equals(td2, type);
if (tdrSig.TypeDefOrRef is TypeRef tr2)
diff --git a/Extensions/dnSpy.AsmEditor/Commands/RootDocumentNodeCreator.cs b/Extensions/dnSpy.AsmEditor/Commands/RootDocumentNodeCreator.cs
index 23848867ba..2a3fcce2d3 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/RootDocumentNodeCreator.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/RootDocumentNodeCreator.cs
@@ -48,7 +48,7 @@ public RootDocumentNodeCreator(IDocumentTreeView documentTreeView, DsDocumentNod
public void Add() {
Debug2.Assert(documentNode.TreeNode.Parent is null);
- if (!(documentNode.TreeNode.Parent is null))
+ if (documentNode.TreeNode.Parent is not null)
throw new InvalidOperationException();
Debug.Assert(!restoreIndex || origIndex >= 0);
@@ -56,7 +56,7 @@ public void Add() {
bool b = documentNode.Document.ModuleDef is null ||
(documentTreeView.FindNode(
- !(documentNode.Document.AssemblyDef is null) ?
+ documentNode.Document.AssemblyDef is not null ?
(object)documentNode.Document.AssemblyDef :
documentNode.Document.ModuleDef) == documentNode);
Debug.Assert(b);
@@ -65,7 +65,7 @@ public void Add() {
}
public void Remove() {
- Debug2.Assert(!(documentNode.TreeNode.Parent is null));
+ Debug2.Assert(documentNode.TreeNode.Parent is not null);
if (documentNode.TreeNode.Parent is null)
throw new InvalidOperationException();
diff --git a/Extensions/dnSpy.AsmEditor/Commands/TypeNodeCreator.cs b/Extensions/dnSpy.AsmEditor/Commands/TypeNodeCreator.cs
index 5c6caf1f4f..6386f65930 100644
--- a/Extensions/dnSpy.AsmEditor/Commands/TypeNodeCreator.cs
+++ b/Extensions/dnSpy.AsmEditor/Commands/TypeNodeCreator.cs
@@ -56,7 +56,7 @@ public TypeNodeCreator(ModuleDocumentNode modNode, List types) {
if (tns != ns)
throw new ArgumentException();
// Can't be a nested type, and can't be part of a module yet
- if (!(t.DeclaringType is null) || !(t.Module is null))
+ if (t.DeclaringType is not null || t.Module is not null)
throw new ArgumentException();
}
ownerList = modNode.Document.ModuleDef!.Types;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/AddClassCommands.cs b/Extensions/dnSpy.AsmEditor/Compiler/AddClassCommands.cs
index 20cc22c3e3..45a3793f45 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/AddClassCommands.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/AddClassCommands.cs
@@ -98,7 +98,7 @@ sealed class CodeCommand : NodesCodeContextMenuHandler {
}
static bool CanExecute(EditCodeVMCreator editCodeVMCreator, DocumentTreeNodeData[] nodes) =>
- editCodeVMCreator.CanCreate(CompilationKind.AddClass) && nodes.Length == 1 && !(GetModuleNode(nodes[0]) is null);
+ editCodeVMCreator.CanCreate(CompilationKind.AddClass) && nodes.Length == 1 && GetModuleNode(nodes[0]) is not null;
static ModuleDocumentNode? GetModuleNode(DocumentTreeNodeData node) {
if (node is AssemblyDocumentNode asmNode) {
@@ -114,11 +114,11 @@ static void Execute(EditCodeVMCreator editCodeVMCreator, Lazy methodAnnotations, Lazy IsVisible(editCodeVMCreator, BodyCommandUtils.GetStatements(context, FindByTextPositionOptions.OuterMostStatement));
static bool IsVisible(EditCodeVMCreator editCodeVMCreator, IList? list) =>
editCodeVMCreator.CanCreate(CompilationKind.EditMethod) &&
- !(list is null) &&
+ list is not null &&
list.Count != 0 &&
- !(list[0].Method.Body is null) &&
+ list[0].Method.Body is not null &&
list[0].Method.Body.Instructions.Count > 0;
public override void Execute(IMenuItemContext context) => Execute(BodyCommandUtils.GetStatements(context, FindByTextPositionOptions.OuterMostStatement));
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/EditAssemblyCommands.cs b/Extensions/dnSpy.AsmEditor/Compiler/EditAssemblyCommands.cs
index 9e32d3e2a9..7b86ead5a7 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/EditAssemblyCommands.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/EditAssemblyCommands.cs
@@ -106,17 +106,17 @@ static void Execute(EditCodeVMCreator editCodeVMCreator, Lazy IsVisible(editCodeVMCreator, BodyCommandUtils.GetStatements(context, FindByTextPositionOptions.OuterMostStatement));
static bool IsVisible(EditCodeVMCreator editCodeVMCreator, IList? list) =>
editCodeVMCreator.CanCreate(CompilationKind.EditClass) &&
- !(list is null) &&
+ list is not null &&
list.Count != 0 &&
- !(list[0].Method.Body is null) &&
+ list[0].Method.Body is not null &&
list[0].Method.Body.Instructions.Count > 0;
public override void Execute(IMenuItemContext context) => Execute(BodyCommandUtils.GetStatements(context, FindByTextPositionOptions.OuterMostStatement));
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/EditClassVM.cs b/Extensions/dnSpy.AsmEditor/Compiler/EditClassVM.cs
index dcbda43aab..a4611eb712 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/EditClassVM.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/EditClassVM.cs
@@ -42,7 +42,7 @@ public EditClassVM(EditCodeVMOptions options, IMemberDef defToEdit, IList(StringComparer.OrdinalIgnoreCase);
- if (!(typeToEdit is null)) {
+ if (typeToEdit is not null) {
Debug.Assert(typeToEdit.Module == sourceModule);
- while (!(typeToEdit.DeclaringType is null))
+ while (typeToEdit.DeclaringType is not null)
typeToEdit = typeToEdit.DeclaringType;
}
tempAssembly = new AssemblyNameInfo {
@@ -339,7 +339,7 @@ async Task StartDecompileAsync() {
for (int i = 0; i < Documents.Count; i++) {
var doc = Documents[i];
var caretSpan = simpleDocuments[i].CaretSpan;
- if (!(caretSpan is null) && caretSpan.Value.End <= doc.TextView.TextSnapshot.Length)
+ if (caretSpan is not null && caretSpan.Value.End <= doc.TextView.TextSnapshot.Length)
doc.Initialize(new SnapshotPoint(doc.TextView.TextSnapshot, caretSpan.Value.Start));
else
doc.Initialize(new SnapshotPoint(doc.TextView.TextSnapshot, 0));
@@ -446,7 +446,7 @@ async Task StartCompileAsync() {
new CompilerDiagnostic(CompilerDiagnosticSeverity.Error, "The task was canceled", "DSWTF!", null, null, null),
};
}
- else if (!(caughtException is null)) {
+ else if (caughtException is not null) {
compilerDiagnostics = new CompilerDiagnostic[] { ToCompilerDiagnostic(caughtException) };
}
else if (result?.Success == true) {
@@ -479,7 +479,7 @@ async Task StartCompileAsync() {
compileCodeState = null;
CanCompile = true;
- if (!(importer is null)) {
+ if (importer is not null) {
Result = importer;
CodeCompiled?.Invoke(this, EventArgs.Empty);
}
@@ -495,7 +495,7 @@ static CompilerDiagnostic ToCompilerDiagnostic(Exception ex) =>
Task CompileAsync() {
Debug2.Assert(compileCodeState is null);
- if (!(compileCodeState is null))
+ if (compileCodeState is not null)
throw new InvalidOperationException();
var state = new CompileCodeState();
compileCodeState = state;
@@ -589,12 +589,12 @@ internal void MoveTo(CompilerDiagnosticVM diag) {
return;
var doc = Documents.FirstOrDefault(a => a.Name == diag.FullPath);
- Debug2.Assert(!(doc is null));
+ Debug2.Assert(doc is not null);
if (doc is null)
return;
SelectedDocument = doc;
- if (!(diag.LineLocationSpan is null)) {
+ if (diag.LineLocationSpan is not null) {
UIUtilities.Focus(doc.TextView.VisualElement, () => {
// The caret isn't always moved unless we wait a little
doc.TextView.VisualElement.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => {
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/EditCodeVMCreator.cs b/Extensions/dnSpy.AsmEditor/Compiler/EditCodeVMCreator.cs
index 113327fa05..4d6cc94dfc 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/EditCodeVMCreator.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/EditCodeVMCreator.cs
@@ -51,7 +51,7 @@ sealed class EditCodeVMCreator {
this.languageCompilerProviders = languageCompilerProviders.OrderBy(a => a.Order).ToArray();
}
- public bool CanCreate(CompilationKind kind) => !(GetLanguageCompilerProvider(kind) is null);
+ public bool CanCreate(CompilationKind kind) => GetLanguageCompilerProvider(kind) is not null;
(IDecompiler decompiler, ILanguageCompilerProvider languageCompilerProvider)? GetLanguageCompilerProvider(CompilationKind kind) {
var language = TryGetUsedLanguage(kind);
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/EditMethodCodeVM.cs b/Extensions/dnSpy.AsmEditor/Compiler/EditMethodCodeVM.cs
index db51cd21c4..93bcee380e 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/EditMethodCodeVM.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/EditMethodCodeVM.cs
@@ -53,7 +53,7 @@ protected override Task DecompileAsync(DecompileCodeState
state.CancellationToken.ThrowIfCancellationRequested();
var type = methodToEdit.DeclaringType;
- while (!(type.DeclaringType is null))
+ while (type.DeclaringType is not null)
type = type.DeclaringType;
DecompileTypeMethods options;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ExistingTypeNodeUpdater.cs b/Extensions/dnSpy.AsmEditor/Compiler/ExistingTypeNodeUpdater.cs
index 26a8d117fd..4efda6ce9a 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ExistingTypeNodeUpdater.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ExistingTypeNodeUpdater.cs
@@ -88,11 +88,11 @@ static HashSet GetSpecialMethods(MergedImportedType type) {
}
foreach (var e in type.NewEvents) {
- if (!(e.AddMethod is null))
+ if (e.AddMethod is not null)
specialMethods.Add(e.AddMethod);
- if (!(e.RemoveMethod is null))
+ if (e.RemoveMethod is not null)
specialMethods.Add(e.RemoveMethod);
- if (!(e.InvokeMethod is null))
+ if (e.InvokeMethod is not null)
specialMethods.Add(e.InvokeMethod);
foreach (var m in e.OtherMethods)
specialMethods.Add(m);
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ImportSigComparer.cs b/Extensions/dnSpy.AsmEditor/Compiler/ImportSigComparer.cs
index 88fa95ed2a..b61a145ad1 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ImportSigComparer.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ImportSigComparer.cs
@@ -205,7 +205,7 @@ bool Equals(IAssembly aAsm, IAssembly bAsm, TypeRef b) {
// Could be an exported type. Resolve it and check again.
var td = b.Resolve(sourceModule);
- return !(td is null) && Equals(aAsm, td.Module.Assembly);
+ return td is not null && Equals(aAsm, td.Module.Assembly);
}
bool Equals(IAssembly aAsm, IAssembly bAsm, ExportedType b) {
@@ -213,7 +213,7 @@ bool Equals(IAssembly aAsm, IAssembly bAsm, ExportedType b) {
return true;
var td = b.Resolve();
- return !(td is null) && Equals(aAsm, td.Module.Assembly);
+ return td is not null && Equals(aAsm, td.Module.Assembly);
}
bool Equals(IAssembly? aAsm, TypeRef a, IAssembly? bAsm, TypeRef b) {
@@ -224,7 +224,7 @@ bool Equals(IAssembly? aAsm, TypeRef a, IAssembly? bAsm, TypeRef b) {
var tda = a.Resolve(sourceModule);
var tdb = b.Resolve(sourceModule);
- return !(tda is null) && !(tdb is null) && Equals(tda.Module.Assembly, tdb.Module.Assembly);
+ return tda is not null && tdb is not null && Equals(tda.Module.Assembly, tdb.Module.Assembly);
}
bool Equals(IAssembly? aAsm, ExportedType a, IAssembly? bAsm, ExportedType b) {
@@ -233,7 +233,7 @@ bool Equals(IAssembly? aAsm, ExportedType a, IAssembly? bAsm, ExportedType b) {
var tda = a.Resolve();
var tdb = b.Resolve();
- return !(tda is null) && !(tdb is null) && Equals(tda.Module.Assembly, tdb.Module.Assembly);
+ return tda is not null && tdb is not null && Equals(tda.Module.Assembly, tdb.Module.Assembly);
}
bool Equals(IAssembly? aAsm, TypeRef a, IAssembly? bAsm, ExportedType b) {
@@ -244,7 +244,7 @@ bool Equals(IAssembly? aAsm, TypeRef a, IAssembly? bAsm, ExportedType b) {
var tda = a.Resolve(sourceModule);
var tdb = b.Resolve();
- return !(tda is null) && !(tdb is null) && Equals(tda.Module.Assembly, tdb.Module.Assembly);
+ return tda is not null && tdb is not null && Equals(tda.Module.Assembly, tdb.Module.Assembly);
}
bool Equals(TypeDef a, IModule bMod, TypeRef b) {
@@ -264,7 +264,7 @@ bool Equals(TypeDef a, FileDef bFile, ExportedType b) {
return true;
var td = b.Resolve();
- return !(td is null) && Equals(a.Module, td.Module) && Equals(a.DefinitionAssembly, td.DefinitionAssembly);
+ return td is not null && Equals(a.Module, td.Module) && Equals(a.DefinitionAssembly, td.DefinitionAssembly);
}
bool TypeDefScopeEquals(TypeDef? a, TypeDef? b) {
@@ -281,7 +281,7 @@ bool Equals(TypeRef a, IModule? ma, TypeRef b, IModule? mb) {
var tda = a.Resolve(sourceModule);
var tdb = b.Resolve(sourceModule);
- return !(tda is null) && !(tdb is null) &&
+ return tda is not null && tdb is not null &&
Equals(tda.Module, tdb.Module) && Equals(tda.DefinitionAssembly, tdb.DefinitionAssembly);
}
@@ -293,7 +293,7 @@ bool Equals(TypeRef a, IModule? ma, ExportedType b, FileDef? fb) {
var tda = a.Resolve(sourceModule);
var tdb = b.Resolve();
- return !(tda is null) && !(tdb is null) &&
+ return tda is not null && tdb is not null &&
Equals(tda.Module, tdb.Module) && Equals(tda.DefinitionAssembly, tdb.DefinitionAssembly);
}
@@ -312,15 +312,15 @@ public bool Equals(IMemberRef? a, IMemberRef? b) {
PropertyDef? pa, pb;
EventDef? ea, eb;
- if (!((ta = a as IType) is null) && !((tb = b as IType) is null))
+ if ((ta = a as IType) is not null && (tb = b as IType) is not null)
result = Equals(ta, tb);
- else if (!((fa = a as IField) is null) && !((fb = b as IField) is null) && fa.IsField && fb.IsField)
+ else if ((fa = a as IField) is not null && (fb = b as IField) is not null && fa.IsField && fb.IsField)
result = Equals(fa, fb);
- else if (!((ma = a as IMethod) is null) && !((mb = b as IMethod) is null))
+ else if ((ma = a as IMethod) is not null && (mb = b as IMethod) is not null)
result = Equals(ma, mb);
- else if (!((pa = a as PropertyDef) is null) && !((pb = b as PropertyDef) is null))
+ else if ((pa = a as PropertyDef) is not null && (pb = b as PropertyDef) is not null)
result = Equals(pa, pb);
- else if (!((ea = a as EventDef) is null) && !((eb = b as EventDef) is null))
+ else if ((ea = a as EventDef) is not null && (eb = b as EventDef) is not null)
result = Equals(ea, eb);
else
result = false;
@@ -342,15 +342,15 @@ public int GetHashCode(IMemberRef? a) {
PropertyDef? pa;
EventDef? ea;
- if (!((ta = a as IType) is null))
+ if ((ta = a as IType) is not null)
result = GetHashCode(ta);
- else if (!((fa = a as IField) is null))
+ else if ((fa = a as IField) is not null)
result = GetHashCode(fa);
- else if (!((ma = a as IMethod) is null))
+ else if ((ma = a as IMethod) is not null)
result = GetHashCode(ma);
- else if (!((pa = a as PropertyDef) is null))
+ else if ((pa = a as PropertyDef) is not null)
result = GetHashCode(pa);
- else if (!((ea = a as EventDef) is null))
+ else if ((ea = a as EventDef) is not null)
result = GetHashCode(ea);
else
result = 0; // Should never be reached
@@ -378,55 +378,55 @@ public bool Equals(IType? a, IType? b) {
TypeSig? sa, sb;
ExportedType? eta, etb;
- if (!((tda = a as TypeDef) is null) & !((tdb = b as TypeDef) is null))
+ if ((tda = a as TypeDef) is not null & (tdb = b as TypeDef) is not null)
result = Equals(tda, tdb);
- else if (!((tra = a as TypeRef) is null) & !((trb = b as TypeRef) is null))
+ else if ((tra = a as TypeRef) is not null & (trb = b as TypeRef) is not null)
result = Equals(tra, trb);
- else if (!((tsa = a as TypeSpec) is null) & !((tsb = b as TypeSpec) is null))
+ else if ((tsa = a as TypeSpec) is not null & (tsb = b as TypeSpec) is not null)
result = Equals(tsa, tsb);
- else if (!((sa = a as TypeSig) is null) & !((sb = b as TypeSig) is null))
+ else if ((sa = a as TypeSig) is not null & (sb = b as TypeSig) is not null)
result = Equals(sa, sb);
- else if (!((eta = a as ExportedType) is null) & !((etb = b as ExportedType) is null))
+ else if ((eta = a as ExportedType) is not null & (etb = b as ExportedType) is not null)
result = Equals(eta, etb);
- else if (!(tda is null) && !(trb is null))
+ else if (tda is not null && trb is not null)
result = Equals(tda, trb); // TypeDef vs TypeRef
- else if (!(tra is null) && !(tdb is null))
+ else if (tra is not null && tdb is not null)
result = Equals(tdb, tra); // TypeDef vs TypeRef
- else if (!(tda is null) && !(tsb is null))
+ else if (tda is not null && tsb is not null)
result = Equals(tda, tsb); // TypeDef vs TypeSpec
- else if (!(tsa is null) && !(tdb is null))
+ else if (tsa is not null && tdb is not null)
result = Equals(tdb, tsa); // TypeDef vs TypeSpec
- else if (!(tda is null) && !(sb is null))
+ else if (tda is not null && sb is not null)
result = Equals(tda, sb); // TypeDef vs TypeSig
- else if (!(sa is null) && !(tdb is null))
+ else if (sa is not null && tdb is not null)
result = Equals(tdb, sa); // TypeDef vs TypeSig
- else if (!(tda is null) && !(etb is null))
+ else if (tda is not null && etb is not null)
result = Equals(tda, etb); // TypeDef vs ExportedType
- else if (!(eta is null) && !(tdb is null))
+ else if (eta is not null && tdb is not null)
result = Equals(tdb, eta); // TypeDef vs ExportedType
- else if (!(tra is null) && !(tsb is null))
+ else if (tra is not null && tsb is not null)
result = Equals(tra, tsb); // TypeRef vs TypeSpec
- else if (!(tsa is null) && !(trb is null))
+ else if (tsa is not null && trb is not null)
result = Equals(trb, tsa); // TypeRef vs TypeSpec
- else if (!(tra is null) && !(sb is null))
+ else if (tra is not null && sb is not null)
result = Equals(tra, sb); // TypeRef vs TypeSig
- else if (!(sa is null) && !(trb is null))
+ else if (sa is not null && trb is not null)
result = Equals(trb, sa); // TypeRef vs TypeSig
- else if (!(tra is null) && !(etb is null))
+ else if (tra is not null && etb is not null)
result = Equals(tra, etb); // TypeRef vs ExportedType
- else if (!(eta is null) && !(trb is null))
+ else if (eta is not null && trb is not null)
result = Equals(trb, eta); // TypeRef vs ExportedType
- else if (!(tsa is null) && !(sb is null))
+ else if (tsa is not null && sb is not null)
result = Equals(tsa, sb); // TypeSpec vs TypeSig
- else if (!(sa is null) && !(tsb is null))
+ else if (sa is not null && tsb is not null)
result = Equals(tsb, sa); // TypeSpec vs TypeSig
- else if (!(tsa is null) && !(etb is null))
+ else if (tsa is not null && etb is not null)
result = Equals(tsa, etb); // TypeSpec vs ExportedType
- else if (!(eta is null) && !(tsb is null))
+ else if (eta is not null && tsb is not null)
result = Equals(tsb, eta); // TypeSpec vs ExportedType
- else if (!(sa is null) && !(etb is null))
+ else if (sa is not null && etb is not null)
result = Equals(sa, etb); // TypeSig vs ExportedType
- else if (!(eta is null) && !(sb is null))
+ else if (eta is not null && sb is not null)
result = Equals(sb, eta); // TypeSig vs ExportedType
else
result = false; // Should never be reached
@@ -448,15 +448,15 @@ public int GetHashCode(IType? a) {
TypeSig? sig;
ExportedType? et;
- if (!((td = a as TypeDef) is null))
+ if ((td = a as TypeDef) is not null)
hash = GetHashCode(td);
- else if (!((tr = a as TypeRef) is null))
+ else if ((tr = a as TypeRef) is not null)
hash = GetHashCode(tr);
- else if (!((ts = a as TypeSpec) is null))
+ else if ((ts = a as TypeSpec) is not null)
hash = GetHashCode(ts);
- else if (!((sig = a as TypeSig) is null))
+ else if ((sig = a as TypeSig) is not null)
hash = GetHashCode(sig);
- else if (!((et = a as ExportedType) is null))
+ else if ((et = a as ExportedType) is not null)
hash = GetHashCode(et);
else
hash = 0; // Should never be reached
@@ -484,19 +484,19 @@ public bool Equals(TypeDef? a, TypeRef? b) {
if (!Equals_TypeNames(a.Name, b.Name) || !Equals_TypeNamespaces(a.Namespace, b.Namespace))
result = false;
- else if (!((dtb = scope as TypeRef) is null)) // nested type
+ else if ((dtb = scope as TypeRef) is not null) // nested type
result = Equals(a.DeclaringType, dtb); // Compare enclosing types
- else if (!(a.DeclaringType is null)) {
+ else if (a.DeclaringType is not null) {
// a is nested, b isn't
result = false;
}
else if (DontCompareTypeScope)
result = true;
- else if (!((bMod = scope as IModule) is null)) // 'b' is defined in the same assembly as 'a'
+ else if ((bMod = scope as IModule) is not null) // 'b' is defined in the same assembly as 'a'
result = Equals(a, bMod, b);
- else if (!((bAsm = scope as AssemblyRef) is null)) {
+ else if ((bAsm = scope as AssemblyRef) is not null) {
var aMod = a.Module;
- result = !(aMod is null) && Equals(aMod.Assembly, bAsm, b);
+ result = aMod is not null && Equals(aMod.Assembly, bAsm, b);
}
else {
result = false;
@@ -528,20 +528,20 @@ public bool Equals(TypeDef? a, ExportedType? b) {
if (!Equals_TypeNames(a.Name, b.TypeName) || !Equals_TypeNamespaces(a.Namespace, b.TypeNamespace))
result = false;
- else if (!((dtb = scope as ExportedType) is null)) { // nested type
+ else if ((dtb = scope as ExportedType) is not null) { // nested type
result = Equals(a.DeclaringType, dtb); // Compare enclosing types
}
- else if (!(a.DeclaringType is null)) {
+ else if (a.DeclaringType is not null) {
result = false; // a is nested, b isn't
}
else if (DontCompareTypeScope)
result = true;
else {
- if (!((bFile = scope as FileDef) is null))
+ if ((bFile = scope as FileDef) is not null)
result = Equals(a, bFile, b);
- else if (!((bAsm = scope as AssemblyRef) is null)) {
+ else if ((bAsm = scope as AssemblyRef) is not null) {
var aMod = a.Module;
- result = !(aMod is null) && Equals(aMod.Assembly, bAsm, b);
+ result = aMod is not null && Equals(aMod.Assembly, bAsm, b);
}
else
result = false;
@@ -764,7 +764,7 @@ public int GetHashCode(TypeDef? a) {
int hash;
hash = GetHashCode_TypeName(a.Name);
- if (!(a.DeclaringType is null))
+ if (a.DeclaringType is not null)
hash += HASHCODE_MAGIC_NESTED_TYPE;
else
hash += GetHashCode_TypeNamespace(a.Namespace);
@@ -812,27 +812,27 @@ bool EqualsResolutionScope(TypeRef? a, TypeRef? b) {
ModuleDef? modDef;
// if one of them is a TypeRef, the other one must be too
- if (!((ea = ra as TypeRef) is null) | !((eb = rb as TypeRef) is null))
+ if ((ea = ra as TypeRef) is not null | (eb = rb as TypeRef) is not null)
result = Equals(ea, eb);
else if (DontCompareTypeScope)
result = true;
// only compare if both are modules
- else if (!((ma = ra as IModule) is null) & !((mb = rb as IModule) is null))
+ else if ((ma = ra as IModule) is not null & (mb = rb as IModule) is not null)
result = Equals(a, ma, b, mb);
// only compare if both are assemblies
- else if (!((aa = ra as AssemblyRef) is null) & !((ab = rb as AssemblyRef) is null))
+ else if ((aa = ra as AssemblyRef) is not null & (ab = rb as AssemblyRef) is not null)
result = Equals(aa, a, ab, b);
- else if (!(aa is null) && rb is ModuleRef) {
+ else if (aa is not null && rb is ModuleRef) {
var bMod = b.Module;
- result = !(bMod is null) && Equals(bMod.Assembly, b, aa, a);
+ result = bMod is not null && Equals(bMod.Assembly, b, aa, a);
}
- else if (!(ab is null) && ra is ModuleRef) {
+ else if (ab is not null && ra is ModuleRef) {
var aMod = a.Module;
- result = !(aMod is null) && Equals(aMod.Assembly, a, ab, b);
+ result = aMod is not null && Equals(aMod.Assembly, a, ab, b);
}
- else if (!(aa is null) && !((modDef = rb as ModuleDef) is null))
+ else if (aa is not null && (modDef = rb as ModuleDef) is not null)
result = Equals(modDef.Assembly, aa, a);
- else if (!(ab is null) && !((modDef = ra as ModuleDef) is null))
+ else if (ab is not null && (modDef = ra as ModuleDef) is not null)
result = Equals(modDef.Assembly, ab, b);
else
result = false;
@@ -861,19 +861,19 @@ bool EqualsImplementation(ExportedType? a, ExportedType? b) {
AssemblyRef? aa, ab;
// if one of them is an ExportedType, the other one must be too
- if (!((ea = ia as ExportedType) is null) | !((eb = ib as ExportedType) is null))
+ if ((ea = ia as ExportedType) is not null | (eb = ib as ExportedType) is not null)
result = Equals(ea, eb);
else if (DontCompareTypeScope)
result = true;
// only compare if both are files
- else if (!((fa = ia as FileDef) is null) & !((fb = ib as FileDef) is null))
+ else if ((fa = ia as FileDef) is not null & (fb = ib as FileDef) is not null)
result = Equals(fa, fb);
// only compare if both are assemblies
- else if (!((aa = ia as AssemblyRef) is null) & !((ab = ib as AssemblyRef) is null))
+ else if ((aa = ia as AssemblyRef) is not null & (ab = ib as AssemblyRef) is not null)
result = Equals(aa, a, ab, b);
- else if (!(fa is null) && !(ab is null))
+ else if (fa is not null && ab is not null)
result = Equals(a.DefinitionAssembly, ab, b);
- else if (!(fb is null) && !(aa is null))
+ else if (fb is not null && aa is not null)
result = Equals(b.DefinitionAssembly, aa, a);
else
result = false;
@@ -904,17 +904,17 @@ bool EqualsScope(TypeRef? a, ExportedType? b) {
AssemblyRef? aa, ab;
// If one is a nested type, the other one must be too
- if (!((ea = ra as TypeRef) is null) | !((eb = ib as ExportedType) is null))
+ if ((ea = ra as TypeRef) is not null | (eb = ib as ExportedType) is not null)
result = Equals(ea, eb);
else if (DontCompareTypeScope)
result = true;
- else if (!((ma = ra as IModule) is null) & !((fb = ib as FileDef) is null))
+ else if ((ma = ra as IModule) is not null & (fb = ib as FileDef) is not null)
result = Equals(a, ma, b, fb);
- else if (!((aa = ra as AssemblyRef) is null) & !((ab = ib as AssemblyRef) is null))
+ else if ((aa = ra as AssemblyRef) is not null & (ab = ib as AssemblyRef) is not null)
result = Equals(aa, a, ab, b);
- else if (!(ma is null) && !(ab is null))
+ else if (ma is not null && ab is not null)
result = Equals(a.DefinitionAssembly, ab, b);
- else if (!(fb is null) && !(aa is null))
+ else if (fb is not null && aa is not null)
result = Equals(b.DefinitionAssembly, aa, a);
else
result = false;
@@ -953,11 +953,11 @@ internal bool Equals(IModule? a, IModule? b) {
return UTF8String.CaseInsensitiveEquals(a.Name, b.Name) || (IsTargetOrSourceModule(a) && IsTargetOrSourceModule(b));
}
- static bool IsCorLib(ModuleDef? a) => !(a is null) && a.IsManifestModule && a.Assembly.IsCorLib();
+ static bool IsCorLib(ModuleDef? a) => a is not null && a.IsManifestModule && a.Assembly.IsCorLib();
static bool IsCorLib(IModule? a) {
var mod = a as ModuleDef;
- return !(mod is null) && mod.IsManifestModule && mod.Assembly.IsCorLib();
+ return mod is not null && mod.IsManifestModule && mod.Assembly.IsCorLib();
}
static bool IsCorLib(IAssembly a) => a.IsCorLib();
@@ -1000,11 +1000,11 @@ bool Equals(IAssembly? a, IAssembly? b) {
}
bool IsTargetOrSourceAssembly(IAssembly? a) => IsTargetAssembly(a) || IsSourceAssembly(a);
- bool IsTargetAssembly(IAssembly? a) => !(a is null) && __AssemblyEquals(a, importOptions.TargetModule.Assembly);
- bool IsSourceAssembly(IAssembly? a) => !(a is null) && __AssemblyEquals(a, importOptions.SourceModule.Assembly);
+ bool IsTargetAssembly(IAssembly? a) => a is not null && __AssemblyEquals(a, importOptions.TargetModule.Assembly);
+ bool IsSourceAssembly(IAssembly? a) => a is not null && __AssemblyEquals(a, importOptions.SourceModule.Assembly);
bool IsTargetOrSourceModule(IModule? a) => IsTargetModule(a) || IsSourceModule(a);
- bool IsTargetModule(IModule? a) => !(a is null) && __ModuleEquals(a, importOptions.TargetModule);
- bool IsSourceModule(IModule? a) => !(a is null) && __ModuleEquals(a, importOptions.SourceModule);
+ bool IsTargetModule(IModule? a) => a is not null && __ModuleEquals(a, importOptions.TargetModule);
+ bool IsSourceModule(IModule? a) => a is not null && __ModuleEquals(a, importOptions.SourceModule);
bool __AssemblyEquals(IAssembly? a, AssemblyDef? b) {
if ((object?)a == b)
return true;
@@ -1349,22 +1349,22 @@ bool Equals(CallingConventionSig? a, CallingConventionSig? b, bool compareHasThi
case CallingConvention.Property:
case CallingConvention.NativeVarArg:
MethodBaseSig ma = (MethodBaseSig)a, mb = (MethodBaseSig)b;
- result = !(ma is null) && !(mb is null) && Equals(ma, mb, compareHasThisFlag);
+ result = ma is not null && mb is not null && Equals(ma, mb, compareHasThisFlag);
break;
case CallingConvention.Field:
FieldSig fa = (FieldSig)a, fb = (FieldSig)b;
- result = !(fa is null) && !(fb is null) && Equals(fa, fb);
+ result = fa is not null && fb is not null && Equals(fa, fb);
break;
case CallingConvention.LocalSig:
LocalSig la = (LocalSig)a, lb = (LocalSig)b;
- result = !(la is null) && !(lb is null) && Equals(la, lb);
+ result = la is not null && lb is not null && Equals(la, lb);
break;
case CallingConvention.GenericInst:
GenericInstMethodSig ga = (GenericInstMethodSig)a, gb = (GenericInstMethodSig)b;
- result = !(ga is null) && !(gb is null) && Equals(ga, gb);
+ result = ga is not null && gb is not null && Equals(ga, gb);
break;
case CallingConvention.Unmanaged:
@@ -1581,15 +1581,15 @@ public bool Equals(IMethod? a, IMethod? b) {
MemberRef? mra, mrb;
MethodSpec? msa, msb;
- if (!((mda = a as MethodDef) is null) & !((mdb = b as MethodDef) is null))
+ if ((mda = a as MethodDef) is not null & (mdb = b as MethodDef) is not null)
result = Equals(mda, mdb);
- else if (!((mra = a as MemberRef) is null) & !((mrb = b as MemberRef) is null))
+ else if ((mra = a as MemberRef) is not null & (mrb = b as MemberRef) is not null)
result = Equals(mra, mrb);
- else if (!((msa = a as MethodSpec) is null) && !((msb = b as MethodSpec) is null))
+ else if ((msa = a as MethodSpec) is not null && (msb = b as MethodSpec) is not null)
result = Equals(msa, msb);
- else if (!(mda is null) && !(mrb is null))
+ else if (mda is not null && mrb is not null)
result = Equals(mda, mrb);
- else if (!(mra is null) && !(mdb is null))
+ else if (mra is not null && mdb is not null)
result = Equals(mdb, mra);
else
result = false;
@@ -1609,11 +1609,11 @@ public int GetHashCode(IMethod? a) {
MemberRef? mra;
MethodSpec? msa;
- if (!((mda = a as MethodDef) is null))
+ if ((mda = a as MethodDef) is not null)
hash = GetHashCode(mda);
- else if (!((mra = a as MemberRef) is null))
+ else if ((mra = a as MemberRef) is not null)
hash = GetHashCode(mra);
- else if (!((msa = a as MethodSpec) is null))
+ else if ((msa = a as MethodSpec) is not null)
hash = GetHashCode(msa);
else
hash = 0;
@@ -1746,18 +1746,18 @@ bool Equals(IMemberRefParent? a, IMemberRefParent? b) {
MethodDef? ma, mb;
TypeDef? td;
- if (!((ita = a as ITypeDefOrRef) is null) && !((itb = b as ITypeDefOrRef) is null))
+ if ((ita = a as ITypeDefOrRef) is not null && (itb = b as ITypeDefOrRef) is not null)
result = Equals((IType)ita, (IType)itb);
- else if (!((moda = a as ModuleRef) is null) & !((modb = b as ModuleRef) is null)) {
+ else if ((moda = a as ModuleRef) is not null & (modb = b as ModuleRef) is not null) {
ModuleDef omoda = moda!.Module, omodb = modb!.Module;
result = Equals((IModule)moda, (IModule)modb) &&
Equals(omoda is null ? null : omoda.Assembly, omodb is null ? null : omodb.Assembly);
}
- else if (!((ma = a as MethodDef) is null) && !((mb = b as MethodDef) is null))
+ else if ((ma = a as MethodDef) is not null && (mb = b as MethodDef) is not null)
result = Equals(ma, mb);
- else if (!(modb is null) && !((td = a as TypeDef) is null))
+ else if (modb is not null && (td = a as TypeDef) is not null)
result = EqualsGlobal(td, modb);
- else if (!(moda is null) && !((td = b as TypeDef) is null))
+ else if (moda is not null && (td = b as TypeDef) is not null)
result = EqualsGlobal(td, moda);
else
result = false;
@@ -1776,11 +1776,11 @@ int GetHashCode(IMemberRefParent? a) {
ITypeDefOrRef? ita;
MethodDef? ma;
- if (!((ita = a as ITypeDefOrRef) is null))
+ if ((ita = a as ITypeDefOrRef) is not null)
hash = GetHashCode((IType)ita);
else if (a is ModuleRef)
hash = GetHashCodeGlobalType();
- else if (!((ma = a as MethodDef) is null)) {
+ else if ((ma = a as MethodDef) is not null) {
// Only use the declaring type so we get the same hash code when hashing a MethodBase.
hash = GetHashCode(ma.DeclaringType);
}
@@ -1803,13 +1803,13 @@ public bool Equals(IField? a, IField? b) {
FieldDef? fa, fb;
MemberRef? ma, mb;
- if (!((fa = a as FieldDef) is null) & !((fb = b as FieldDef) is null))
+ if ((fa = a as FieldDef) is not null & (fb = b as FieldDef) is not null)
result = Equals(fa, fb);
- else if (!((ma = a as MemberRef) is null) & !((mb = b as MemberRef) is null))
+ else if ((ma = a as MemberRef) is not null & (mb = b as MemberRef) is not null)
result = Equals(ma, mb);
- else if (!(fa is null) && !(mb is null))
+ else if (fa is not null && mb is not null)
result = Equals(fa, mb);
- else if (!(fb is null) && !(ma is null))
+ else if (fb is not null && ma is not null)
result = Equals(fb, ma);
else
result = false;
@@ -1828,9 +1828,9 @@ public int GetHashCode(IField? a) {
FieldDef? fa;
MemberRef? ma;
- if (!((fa = a as FieldDef) is null))
+ if ((fa = a as FieldDef) is not null)
hash = GetHashCode(fa);
- else if (!((ma = a as MemberRef) is null))
+ else if ((ma = a as MemberRef) is not null)
hash = GetHashCode(ma);
else
hash = 0;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/BlobMDHeap.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/BlobMDHeap.cs
index a453e991ed..cf8a5504b6 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/BlobMDHeap.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/BlobMDHeap.cs
@@ -79,6 +79,6 @@ byte[] GetLengthBytes(uint value) {
}
public override bool MustRewriteHeap() => newData.Count > 0;
- public override bool ExistsInMetadata => !(blobStream.StreamHeader is null);
+ public override bool ExistsInMetadata => blobStream.StreamHeader is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/GuidMDHeap.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/GuidMDHeap.cs
index b4709af2a3..350cd285c6 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/GuidMDHeap.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/GuidMDHeap.cs
@@ -41,6 +41,6 @@ public GuidMDHeap(MetadataEditor mdEditor, GuidStream guidStream) {
}
public override bool MustRewriteHeap() => newData.Count > 0;
- public override bool ExistsInMetadata => !(guidStream.StreamHeader is null);
+ public override bool ExistsInMetadata => guidStream.StreamHeader is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/ImageCor20HeaderSectionData.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/ImageCor20HeaderSectionData.cs
index 37026f2ae8..f5ef1e3fc4 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/ImageCor20HeaderSectionData.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/ImageCor20HeaderSectionData.cs
@@ -70,7 +70,7 @@ public override void Finish(MDWriter mdWriter, MDWriterStream stream) {
stream.Write(mdData.RVA);
stream.Write(mdData.Size);
- if (!(snData is null)) {
+ if (snData is not null) {
stream.Position = cor20HeaderStrongnameDataDirPosition;
Debug.Assert(snData.RVA != 0);
Debug.Assert(snData.Size != 0);
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/MDWriter.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/MDWriter.cs
index c3f916f097..fc69fc50bd 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/MDWriter.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/MDWriter.cs
@@ -95,7 +95,7 @@ public void Write() {
if ((cor20.Flags & ComImageFlags.StrongNameSigned) != 0 && cor20.StrongNameSignature.Size != 0 && cor20.StrongNameSignature.VirtualAddress != 0)
snData = new StrongNameSignatureSectionData(cor20.StrongNameSignature.Size);
- if (!(snData is null))
+ if (snData is not null)
textSection.SectionData.Add(snData);
var mdData = new DotNetMetadataSectionData(mdEditor);
textSection.SectionData.Add(new ImageCor20HeaderSectionData(mdData, snData));
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/StringsMDHeap.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/StringsMDHeap.cs
index 1671917c72..1d7efc8f8c 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/StringsMDHeap.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/StringsMDHeap.cs
@@ -74,6 +74,6 @@ static void CheckValidName(byte[] bytes) {
}
public override bool MustRewriteHeap() => newData.Count > 0;
- public override bool ExistsInMetadata => !(stringsStream.StreamHeader is null);
+ public override bool ExistsInMetadata => stringsStream.StreamHeader is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesHeapWriter.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesHeapWriter.cs
index 1cfdd3b360..51292af17a 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesHeapWriter.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesHeapWriter.cs
@@ -105,7 +105,7 @@ public unsafe override void Write(MDWriter mdWriter, MDWriterStream stream, byte
if (tablesToIgnore[i])
continue;
var info = infos[i];
- if (!(info is null) && !info.IsEmpty) {
+ if (info is not null && !info.IsEmpty) {
rowCounts[i] = info.Rows;
stream.Write(info.Rows);
}
@@ -123,7 +123,7 @@ public unsafe override void Write(MDWriter mdWriter, MDWriterStream stream, byte
if (tablesToIgnore[i])
continue;
var info = infos[i];
- if (!(info is null) && !info.IsEmpty)
+ if (info is not null && !info.IsEmpty)
totalSize += (long)info.Rows * tableInfos[i].RowSize;
}
@@ -211,7 +211,7 @@ static ulong GetValidMask(TablesMDHeap tablesHeap) {
if (tablesToIgnore[i])
continue;
var info = infos[i];
- if (!(info is null) && !info.IsEmpty)
+ if (info is not null && !info.IsEmpty)
mask |= 1UL << i;
}
return mask;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesMDHeap.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesMDHeap.cs
index 9ca231e08d..4c4b4cae54 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesMDHeap.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/TablesMDHeap.cs
@@ -295,6 +295,6 @@ public override bool MustRewriteHeap() {
return false;
}
- public override bool ExistsInMetadata => !(tablesStream.StreamHeader is null);
+ public override bool ExistsInMetadata => tablesStream.StreamHeader is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/USMDHeap.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/USMDHeap.cs
index 1d8fc4a4d3..abb8065657 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/USMDHeap.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/USMDHeap.cs
@@ -31,6 +31,6 @@ public USMDHeap(MetadataEditor mdEditor, USStream usStream) {
}
public override bool MustRewriteHeap() => false;
- public override bool ExistsInMetadata => !(usStream.StreamHeader is null);
+ public override bool ExistsInMetadata => usStream.StreamHeader is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/UnknownMDHeap.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/UnknownMDHeap.cs
index b90c9a94b2..174ea2894e 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/UnknownMDHeap.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditor/UnknownMDHeap.cs
@@ -31,6 +31,6 @@ public UnknownMDHeap(MetadataEditor mdEditor, DotNetStream stream) {
}
public override bool MustRewriteHeap() => false;
- public override bool ExistsInMetadata => !(stream.StreamHeader is null);
+ public override bool ExistsInMetadata => stream.StreamHeader is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDEditorPatcher.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDEditorPatcher.cs
index 53f9925a92..d826eeea6f 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDEditorPatcher.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDEditorPatcher.cs
@@ -66,7 +66,7 @@ uint GetOrCreateTempAssemblyRid() {
}
public void Patch(ModuleDef module) {
- if (UpdateTypeReferences && !(nonNestedEditedType is null)) {
+ if (UpdateTypeReferences && nonNestedEditedType is not null) {
if (nonNestedEditedType.Module == module)
DeleteTypeDef(mdEditor, nonNestedEditedType);
PatchTypeRefsToEditedType(nonNestedEditedType);
@@ -101,7 +101,7 @@ void DeleteTypeDef(MetadataEditor mdEditor, TypeDef nonNestedTypeDef) {
foreach (var kv in dict) {
var deletedType = kv.Value;
uint resolutionScope;
- if (!(deletedType.Type.DeclaringType is null)) {
+ if (deletedType.Type.DeclaringType is not null) {
var declType = dict[deletedType.Type.DeclaringType];
resolutionScope = CodedToken.ResolutionScope.Encode(new MDToken(Table.TypeRef, declType.TypeRefRid));
}
@@ -486,7 +486,7 @@ uint PatchTypeSignature(Dictionary typeSigDict, uint sig) {
return newSig;
var data = MDSigPatcher.PatchTypeSignature(sigBuilder, remappedTypeTokens, moduleData, (uint)mdEditor.RealMetadata.BlobStream.StartOffset, sig);
- if (!(data is null))
+ if (data is not null)
newSig = mdEditor.BlobHeap.Create(data);
else
newSig = sig;
@@ -504,7 +504,7 @@ uint PatchCallingConventionSignature(Dictionary callConvSigDict, uin
return newSig;
var data = MDSigPatcher.PatchCallingConventionSignature(sigBuilder, remappedTypeTokens, moduleData, (uint)mdEditor.RealMetadata.BlobStream.StartOffset, sig);
- if (!(data is null))
+ if (data is not null)
newSig = mdEditor.BlobHeap.Create(data);
else
newSig = sig;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MDPatcherUtils.cs b/Extensions/dnSpy.AsmEditor/Compiler/MDPatcherUtils.cs
index 5378f69926..f94c45fa91 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MDPatcherUtils.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MDPatcherUtils.cs
@@ -68,7 +68,7 @@ public unsafe static uint ReadCompressedUInt32(ref byte* data, byte* end) {
(*data++ << 8) | *data++);
}
- public static bool ExistsInMetadata(TypeDef? type) => !(type is null) && !(type is TypeDefUser);
+ public static bool ExistsInMetadata(TypeDef? type) => type is not null && !(type is TypeDefUser);
public static bool ReferencesModule(ModuleDef sourceModule, ModuleDef? targetModule) {
if (targetModule is null)
@@ -78,7 +78,7 @@ public static bool ReferencesModule(ModuleDef sourceModule, ModuleDef? targetMod
return true;
var targetAssembly = targetModule.Assembly;
- if (!(targetAssembly is null)) {
+ if (targetAssembly is not null) {
// Don't compare version, there could be binding redirects
var asmComparer = new AssemblyNameComparer(AssemblyNameComparerFlags.Name | AssemblyNameComparerFlags.PublicKeyToken | AssemblyNameComparerFlags.Culture | AssemblyNameComparerFlags.ContentType);
foreach (var asmRef in sourceModule.GetAssemblyRefs()) {
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/MergeWithAssemblyCommand.cs b/Extensions/dnSpy.AsmEditor/Compiler/MergeWithAssemblyCommand.cs
index 853dbd5dea..98d5e17eab 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/MergeWithAssemblyCommand.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/MergeWithAssemblyCommand.cs
@@ -95,7 +95,7 @@ sealed class CodeCommand : NodesCodeContextMenuHandler {
public override void Execute(CodeContext context) => MergeWithAssemblyCommand.Execute(pickFilename, addUpdatedNodesHelperProvider, undoCommandService, appService, context.Nodes);
}
- static bool CanExecute(DocumentTreeNodeData[] nodes) => nodes.Length == 1 && !(GetModuleNode(nodes[0]) is null);
+ static bool CanExecute(DocumentTreeNodeData[] nodes) => nodes.Length == 1 && GetModuleNode(nodes[0]) is not null;
static ModuleDocumentNode? GetModuleNode(DocumentTreeNodeData node) {
if (node is AssemblyDocumentNode asmNode) {
@@ -111,11 +111,11 @@ static void Execute(IPickFilename pickFilename, Lazy extraAssemblyReferences) {
IEnumerable GetAssemblies(ModuleDef module, IEnumerable extraAssemblyReferences) {
var asm = module.Assembly;
- if (!(asm is null)) {
+ if (asm is not null) {
foreach (var a in GetAssemblies(asm))
yield return a;
}
@@ -79,7 +79,7 @@ IEnumerable GetAssemblyRefs(ModuleDef module, IEnumerable ext
yield return a;
foreach (var s in extraAssemblyReferences) {
var info = new AssemblyNameInfo(s);
- if (!(info.Version is null))
+ if (info.Version is not null)
yield return info;
}
}
@@ -134,7 +134,7 @@ IEnumerable GetResolvedContractAssemblies(ModuleDef module) {
checkedContractsAssemblies.Add(asmRef);
var contractsAsm = module.Context.AssemblyResolver.Resolve(asmRef, module);
- if (!(contractsAsm is null)) {
+ if (contractsAsm is not null) {
yield return contractsAsm;
foreach (var m in contractsAsm.Modules) {
foreach (var ar in m.GetAssemblyRefs()) {
@@ -150,7 +150,7 @@ IEnumerable GetResolvedContractAssemblies(ModuleDef module) {
foreach (var asmRef in nonContractAsms) {
cancellationToken.ThrowIfCancellationRequested();
var asm = module.Context.AssemblyResolver.Resolve(asmRef, module);
- if (!(asm is null))
+ if (asm is not null)
yield return asm;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.MemberLookup.cs b/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.MemberLookup.cs
index 7525e0920c..ad0a304c8e 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.MemberLookup.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.MemberLookup.cs
@@ -92,7 +92,7 @@ public void Initialize(TypeDef targetType) {
return null;
foreach (var o in compiledMethod.Overrides) {
var targetMethod = LookupOverride(o);
- if (!(targetMethod is null))
+ if (targetMethod is not null)
return targetMethod.DeclaringType.Properties.First(a => a.GetMethod == targetMethod || a.SetMethod == targetMethod);
}
return null;
@@ -109,7 +109,7 @@ public void Initialize(TypeDef targetType) {
return null;
foreach (var o in compiledMethod.Overrides) {
var targetMethod = LookupOverride(o);
- if (!(targetMethod is null))
+ if (targetMethod is not null)
return targetMethod.DeclaringType.Events.First(a => a.AddMethod == targetMethod || a.RemoveMethod == targetMethod || a.InvokeMethod == targetMethod);
}
return null;
@@ -121,7 +121,7 @@ public void Initialize(TypeDef targetType) {
return targetMethod;
foreach (var o in compiledMethod.Overrides) {
targetMethod = LookupOverride(o);
- if (!(targetMethod is null))
+ if (targetMethod is not null)
return targetMethod;
}
return null;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.cs b/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.cs
index d8e8a5f295..308bb88ab0 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporter.cs
@@ -377,7 +377,7 @@ public void Import(byte[] rawGeneratedModule, DebugFileResult debugFile, ModuleI
RemoveDuplicates(attributes, "System.Security.UnverifiableCodeAttribute");
NewModuleCustomAttributes = attributes.ToArray();
var asm = sourceModule.Assembly;
- if (!(asm is null)) {
+ if (asm is not null) {
NewAssemblyVersion = asm.Version;
attributes.Clear();
ImportCustomAttributes(attributes, asm);
@@ -387,7 +387,7 @@ public void Import(byte[] rawGeneratedModule, DebugFileResult debugFile, ModuleI
if ((options & ModuleImporterOptions.ReplaceAssemblyDeclSecurities) != 0) {
var asm = sourceModule.Assembly;
- if (!(asm is null)) {
+ if (asm is not null) {
var declSecs = new List();
ImportDeclSecurities(declSecs, asm);
// The C# compiler always adds this security attribute:
@@ -417,12 +417,12 @@ public void Import(byte[] rawGeneratedModule, DebugFileResult debugFile, ModuleI
public void Import(byte[] rawGeneratedModule, DebugFileResult debugFile, TypeDef targetType) {
if (targetType.Module != targetModule)
throw new InvalidOperationException();
- if (!(targetType.DeclaringType is null))
+ if (targetType.DeclaringType is not null)
throw new ArgumentException("Type must not be nested");
SetSourceModule(LoadModule(rawGeneratedModule, debugFile));
var newType = FindSourceType(targetType);
- if (!(newType.DeclaringType is null))
+ if (newType.DeclaringType is not null)
throw new ArgumentException("Type must not be nested");
RenamePropEventAccessors(newType, targetType);
@@ -444,7 +444,7 @@ public void Import(byte[] rawGeneratedModule, DebugFileResult debugFile, TypeDef
TypeDef FindSourceType(TypeDef targetType) {
var newType = sourceModule.Find(targetType.Module.Import(targetType));
- if (!(newType is null))
+ if (newType is not null)
return newType;
AddErrorThrow(IM0010, string.Format(dnSpy_AsmEditor_Resources.ERR_IM_CouldNotFindEditedType, targetType));
@@ -460,12 +460,12 @@ TypeDef FindSourceType(TypeDef targetType) {
public void ImportNewMembers(byte[] rawGeneratedModule, DebugFileResult debugFile, TypeDef targetType) {
if (targetType.Module != targetModule)
throw new InvalidOperationException();
- if (!(targetType.DeclaringType is null))
+ if (targetType.DeclaringType is not null)
throw new ArgumentException("Type must not be nested");
SetSourceModule(LoadModule(rawGeneratedModule, debugFile));
var newType = FindSourceType(targetType);
- if (!(newType.DeclaringType is null))
+ if (newType.DeclaringType is not null)
throw new ArgumentException("Type must not be nested");
RenamePropEventAccessors(newType, targetType);
@@ -564,7 +564,7 @@ MergedImportedType MergeEditedTypes(TypeDef newType, TypeDef targetType) {
InitializeNewStateMachineTypes(newType);
- Debug2.Assert(!(importSigComparerOptions is null));
+ Debug2.Assert(importSigComparerOptions is not null);
var fieldDiff = new FieldMemberDiff(importSigComparerOptions, targetModule);
fieldDiff.Initialize(newType, targetType, mergedImportedType);
var methodDiff = new MethodMemberDiff(importSigComparerOptions, targetModule);
@@ -642,7 +642,7 @@ MergedImportedType MergeEditedTypes(TypeDef newType, TypeDef targetType) {
void InitializeNewStateMachineTypes(TypeDef compiledType) {
foreach (var method in compiledType.Methods) {
var smType = StateMachineHelpers.GetStateMachineType(method);
- if (!(smType is null)) {
+ if (smType is not null) {
Debug.Assert(!newStateMachineTypes.Contains(smType), "Two or more methods share the same state machine type");
newStateMachineTypes.Add(smType);
}
@@ -667,7 +667,7 @@ public void Import(byte[] rawGeneratedModule, DebugFileResult debugFile, MethodD
var newMethod = FindSourceMethod(targetMethod);
var newMethodNonNestedDeclType = newMethod.DeclaringType;
- while (!(newMethodNonNestedDeclType.DeclaringType is null))
+ while (newMethodNonNestedDeclType.DeclaringType is not null)
newMethodNonNestedDeclType = newMethodNonNestedDeclType.DeclaringType;
RenamePropEventAccessors(newMethod.DeclaringType, targetMethod.DeclaringType);
@@ -764,7 +764,7 @@ MethodDef FindSourceMethod(MethodDef targetMethod) {
const SigComparerOptions comparerFlags = SIG_COMPARER_OPTIONS | SigComparerOptions.DontCompareTypeScope;
var newMethod = newType!.FindMethod(GetMethodName(targetMethod), targetMethod.MethodSig, comparerFlags, targetMethod.Module);
- if (!(newMethod is null))
+ if (newMethod is not null)
return newMethod;
if (targetMethod.Overrides.Count != 0) {
@@ -856,17 +856,17 @@ void UpdateEditedMethods() {
void AddEditedMethod(MethodDef newMethod, MethodDef targetMethod) {
var newBaseType = newMethod.DeclaringType;
var targetBaseType = targetMethod.DeclaringType;
- while (!(newBaseType.DeclaringType is null)) {
+ while (newBaseType.DeclaringType is not null) {
if (targetBaseType is null)
throw new InvalidOperationException();
newBaseType = newBaseType.DeclaringType;
targetBaseType = targetBaseType.DeclaringType;
}
- if (targetBaseType is null || !(targetBaseType.DeclaringType is null))
+ if (targetBaseType is null || targetBaseType.DeclaringType is not null)
throw new InvalidOperationException();
var newStateMachineType = StateMachineHelpers.GetStateMachineType(newMethod);
- if (!(newStateMachineType is null))
+ if (newStateMachineType is not null)
newStateMachineTypes.Add(newStateMachineType);
nonNestedMergedImportedTypes.Add(AddMergedType(newBaseType, targetBaseType));
editedMethodsToFix.Add(newMethod, targetMethod);
@@ -950,7 +950,7 @@ MergedImportedType MergeTypesRename(TypeDef newType, TypeDef targetType) {
void RenameMergedMembers(MergedImportedType mergedType) {
if (mergedType.MergeKind != MergeKind.Rename)
throw new InvalidOperationException();
- Debug2.Assert(!(importSigComparerOptions is null));
+ Debug2.Assert(importSigComparerOptions is not null);
var existingProps = new HashSet(new ImportPropertyEqualityComparer(new ImportSigComparer(importSigComparerOptions, SIG_COMPARER_OPTIONS | SigComparerOptions.DontCompareReturnType, targetModule)));
var existingMethods = new HashSet(new ImportMethodEqualityComparer(new ImportSigComparer(importSigComparerOptions, SIG_COMPARER_OPTIONS | SigComparerOptions.DontCompareReturnType, targetModule)));
var existingEventsFields = new HashSet(StringComparer.Ordinal);
@@ -979,9 +979,9 @@ void RenameMergedMembers(MergedImportedType mergedType) {
while (existingProps.Contains(newProp))
newProp.Name = origName + "_" + (counter++).ToString();
existingProps.Add(newProp);
- if (!(newProp.GetMethod is null))
+ if (newProp.GetMethod is not null)
suggestedNames[newProp.GetMethod] = "get_" + newProp.Name;
- if (!(newProp.SetMethod is null))
+ if (newProp.SetMethod is not null)
suggestedNames[newProp.SetMethod] = "set_" + newProp.Name;
}
@@ -998,11 +998,11 @@ void RenameMergedMembers(MergedImportedType mergedType) {
while (existingEventsFields.Contains(newEvent.Name))
newEvent.Name = origName + "_" + (counter++).ToString();
existingEventsFields.Add(newEvent.Name);
- if (!(newEvent.AddMethod is null))
+ if (newEvent.AddMethod is not null)
suggestedNames[newEvent.AddMethod] = "add_" + newEvent.Name;
- if (!(newEvent.RemoveMethod is null))
+ if (newEvent.RemoveMethod is not null)
suggestedNames[newEvent.RemoveMethod] = "remove_" + newEvent.Name;
- if (!(newEvent.InvokeMethod is null))
+ if (newEvent.InvokeMethod is not null)
suggestedNames[newEvent.InvokeMethod] = "raise_" + newEvent.Name;
}
@@ -1216,11 +1216,11 @@ void AddUsedMethods(ImportedType importedType) {
usedMethods.Add(m);
}
foreach (var p in importedType.TargetType.Events) {
- if (!(p.AddMethod is null))
+ if (p.AddMethod is not null)
usedMethods.Add(p.AddMethod);
- if (!(p.InvokeMethod is null))
+ if (p.InvokeMethod is not null)
usedMethods.Add(p.InvokeMethod);
- if (!(p.RemoveMethod is null))
+ if (p.RemoveMethod is not null)
usedMethods.Add(p.RemoveMethod);
foreach (var m in p.OtherMethods)
usedMethods.Add(m);
@@ -1228,7 +1228,7 @@ void AddUsedMethods(ImportedType importedType) {
}
void InitializeTypesStep1(IEnumerable importedTypes) {
- Debug2.Assert(!(importSigComparerOptions is null));
+ Debug2.Assert(importSigComparerOptions is not null);
var memberDict = new MemberLookup(new ImportSigComparer(importSigComparerOptions, SIG_COMPARER_BASE_OPTIONS, targetModule));
foreach (var importedType in importedTypes) {
var compiledType = toExtraData[importedType].CompiledType;
@@ -1254,7 +1254,7 @@ void InitializeTypesStep1(IEnumerable importedTypes) {
foreach (var compiledField in compiledType.Fields) {
FieldDef? targetField;
- if (!((targetField = memberDict.FindField(compiledField)) is null)) {
+ if ((targetField = memberDict.FindField(compiledField)) is not null) {
memberDict.Remove(targetField);
isStub.Add(compiledField);
isStub.Add(targetField);
@@ -1266,7 +1266,7 @@ void InitializeTypesStep1(IEnumerable importedTypes) {
}
foreach (var compiledMethod in compiledType.Methods) {
MethodDef? targetMethod;
- if (!((targetMethod = memberDict.FindMethod(compiledMethod)) is null) || editedMethodsToFix.TryGetValue(compiledMethod, out targetMethod)) {
+ if ((targetMethod = memberDict.FindMethod(compiledMethod)) is not null || editedMethodsToFix.TryGetValue(compiledMethod, out targetMethod)) {
memberDict.Remove(targetMethod);
isStub.Add(compiledMethod);
isStub.Add(targetMethod);
@@ -1278,7 +1278,7 @@ void InitializeTypesStep1(IEnumerable importedTypes) {
}
foreach (var compiledProperty in compiledType.Properties) {
PropertyDef? targetProperty;
- if (!((targetProperty = memberDict.FindProperty(compiledProperty)) is null)) {
+ if ((targetProperty = memberDict.FindProperty(compiledProperty)) is not null) {
memberDict.Remove(targetProperty);
isStub.Add(compiledProperty);
isStub.Add(targetProperty);
@@ -1290,7 +1290,7 @@ void InitializeTypesStep1(IEnumerable importedTypes) {
}
foreach (var compiledEvent in compiledType.Events) {
EventDef? targetEvent;
- if (!((targetEvent = memberDict.FindEvent(compiledEvent)) is null)) {
+ if ((targetEvent = memberDict.FindEvent(compiledEvent)) is not null) {
memberDict.Remove(targetEvent);
isStub.Add(compiledEvent);
isStub.Add(targetEvent);
@@ -1360,7 +1360,7 @@ void Initialize(TypeDef compiledType, TypeDef targetType, TypeDefOptions options
}
void InitializeTypesStep2(IEnumerable importedTypes) {
- Debug2.Assert(!(importSigComparerOptions is null));
+ Debug2.Assert(importSigComparerOptions is not null);
var memberDict = new MemberLookup(new ImportSigComparer(importSigComparerOptions, SIG_COMPARER_BASE_OPTIONS, targetModule));
foreach (var importedType in importedTypes) {
var compiledType = toExtraData[importedType].CompiledType;
@@ -1389,7 +1389,7 @@ void InitializeTypesStep2(IEnumerable importedTypes) {
foreach (var compiledField in compiledType.Fields) {
FieldDef? targetField;
- if (!((targetField = memberDict.FindField(compiledField)) is null)) {
+ if ((targetField = memberDict.FindField(compiledField)) is not null) {
Initialize(compiledField);
memberDict.Remove(targetField);
}
@@ -1398,7 +1398,7 @@ void InitializeTypesStep2(IEnumerable importedTypes) {
}
foreach (var compiledMethod in compiledType.Methods) {
MethodDef? targetMethod;
- if (!((targetMethod = memberDict.FindMethod(compiledMethod)!) is null) || editedMethodsToFix.TryGetValue(compiledMethod, out targetMethod)) {
+ if ((targetMethod = memberDict.FindMethod(compiledMethod)!) is not null || editedMethodsToFix.TryGetValue(compiledMethod, out targetMethod)) {
Initialize(compiledMethod);
memberDict.Remove(targetMethod);
}
@@ -1407,7 +1407,7 @@ void InitializeTypesStep2(IEnumerable importedTypes) {
}
foreach (var compiledProperty in compiledType.Properties) {
PropertyDef? targetProperty;
- if (!((targetProperty = memberDict.FindProperty(compiledProperty)) is null)) {
+ if ((targetProperty = memberDict.FindProperty(compiledProperty)) is not null) {
Initialize(compiledProperty);
memberDict.Remove(targetProperty);
}
@@ -1416,7 +1416,7 @@ void InitializeTypesStep2(IEnumerable importedTypes) {
}
foreach (var compiledEvent in compiledType.Events) {
EventDef? targetEvent;
- if (!((targetEvent = memberDict.FindEvent(compiledEvent)) is null)) {
+ if ((targetEvent = memberDict.FindEvent(compiledEvent)) is not null) {
Initialize(compiledEvent);
memberDict.Remove(targetEvent);
}
@@ -1488,7 +1488,7 @@ void InitializeTypesMethods(IEnumerable importedTypes) {
return null;
var res = TryGetTypeInTargetModule(type, out var importedType);
- if (!(res is null))
+ if (res is not null)
return res;
if (type is TypeRef tr)
@@ -1564,7 +1564,7 @@ void InitializeTypesMethods(IEnumerable importedTypes) {
var tr2 = (TypeRef)tr.GetNonNestedTypeRefScope();
if (IsTarget(tr2.ResolutionScope)) {
td = targetModule.Find(tr);
- if (!(td is null)) {
+ if (td is not null) {
importedType = null;
return td;
}
@@ -1609,8 +1609,8 @@ bool IsTarget(IResolutionScope scope) {
bool IsTarget(ModuleRef modRef) => StringComparer.OrdinalIgnoreCase.Equals(modRef?.Name, targetModule.Name);
// The type/method could be in some external assembly, eg. System.Private.CoreLib, don't return those defs.
- TypeDef? TryImportTypeDef(TypeDef? type) => !(type is null) && oldTypeToNewType.TryGetValue(type, out var importedType) ? importedType.TargetType : null;
- MethodDef? TryImportMethodDef(MethodDef? method) => !(method is null) && oldMethodToNewMethod.TryGetValue(method, out var importedMethod) ? importedMethod.TargetMember : null;
+ TypeDef? TryImportTypeDef(TypeDef? type) => type is not null && oldTypeToNewType.TryGetValue(type, out var importedType) ? importedType.TargetType : null;
+ MethodDef? TryImportMethodDef(MethodDef? method) => method is not null && oldMethodToNewMethod.TryGetValue(method, out var importedMethod) ? importedMethod.TargetMember : null;
TypeSig? Import(TypeSig type) {
if (type is null)
@@ -1679,7 +1679,7 @@ bool IsTarget(IResolutionScope scope) {
TypeSig CreateClassOrValueType(ITypeDefOrRef type, bool isValueType) {
var corLibType = targetModule.CorLibTypes.GetCorLibTypeSig(type);
- if (!(corLibType is null))
+ if (corLibType is not null)
return corLibType;
if (isValueType)
@@ -1876,7 +1876,7 @@ T Import(T sig, T old) where T : MethodBaseSig {
sig.Params.Add(Import(p));
sig.GenParamCount = old.GenParamCount;
var paramsAfterSentinel = sig.ParamsAfterSentinel;
- if (!(paramsAfterSentinel is null)) {
+ if (paramsAfterSentinel is not null) {
foreach (var p in old.ParamsAfterSentinel)
paramsAfterSentinel.Add(Import(p));
}
@@ -2019,17 +2019,17 @@ void Create(EventDef eventDef) {
importedPropertyDef.Constant = Import(propDef.Constant);
foreach (var m in propDef.GetMethods) {
var newMethod = TryGetMethod(m);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedPropertyDef.GetMethods.Add(newMethod);
}
foreach (var m in propDef.SetMethods) {
var newMethod = TryGetMethod(m);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedPropertyDef.SetMethods.Add(newMethod);
}
foreach (var m in propDef.OtherMethods) {
var newMethod = TryGetMethod(m);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedPropertyDef.OtherMethods.Add(newMethod);
}
return importedPropertyDef;
@@ -2052,24 +2052,24 @@ void Create(EventDef eventDef) {
importedEventDef.EventType = Import(eventDef.EventType);
importedEventDef.Attributes = eventDef.Attributes;
ImportCustomAttributes(importedEventDef, eventDef);
- if (!(eventDef.AddMethod is null)) {
+ if (eventDef.AddMethod is not null) {
var newMethod = TryGetMethod(eventDef.AddMethod);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedEventDef.AddMethod = newMethod;
}
- if (!(eventDef.InvokeMethod is null)) {
+ if (eventDef.InvokeMethod is not null) {
var newMethod = TryGetMethod(eventDef.InvokeMethod);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedEventDef.InvokeMethod = newMethod;
}
- if (!(eventDef.RemoveMethod is null)) {
+ if (eventDef.RemoveMethod is not null) {
var newMethod = TryGetMethod(eventDef.RemoveMethod);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedEventDef.RemoveMethod = newMethod;
}
foreach (var m in eventDef.OtherMethods) {
var newMethod = TryGetMethod(m);
- if (!(newMethod is null))
+ if (newMethod is not null)
importedEventDef.OtherMethods.Add(newMethod);
}
return importedEventDef;
@@ -2188,13 +2188,13 @@ void Create(EventDef eventDef) {
var mr = (MemberRef)method;
var td = TryGetTypeInTargetModule(mr.Class as ITypeDefOrRef, out var importedType);
- if (!(td is null)) {
+ if (td is not null) {
var targetMethod = FindMethod(td, mr);
- if (!(targetMethod is null))
+ if (targetMethod is not null)
return targetMethod;
- if (!(importedType is null)) {
+ if (importedType is not null) {
var compiledMethod = FindMethod(toExtraData[importedType].CompiledType, mr);
- if (!(compiledMethod is null))
+ if (compiledMethod is not null)
return oldMethodToNewMethod[compiledMethod].TargetMember;
}
@@ -2206,7 +2206,7 @@ void Create(EventDef eventDef) {
}
MethodDef? FindMethod(TypeDef targetType, MemberRef mr) {
- Debug2.Assert(!(importSigComparerOptions is null));
+ Debug2.Assert(importSigComparerOptions is not null);
var comparer = new ImportSigComparer(importSigComparerOptions, SIG_COMPARER_OPTIONS, targetModule);
foreach (var method in targetType.Methods) {
if (!UTF8String.Equals(method.Name, mr.Name))
@@ -2226,13 +2226,13 @@ void Create(EventDef eventDef) {
var mr = (MemberRef)field;
var td = TryGetTypeInTargetModule(mr.Class as ITypeDefOrRef, out var importedType);
- if (!(td is null)) {
+ if (td is not null) {
var targetField = FindField(td, mr);
- if (!(targetField is null))
+ if (targetField is not null)
return targetField;
- if (!(importedType is null)) {
+ if (importedType is not null) {
var compiledField = FindField(toExtraData[importedType].CompiledType, mr);
- if (!(compiledField is null))
+ if (compiledField is not null)
return oldFieldToNewField[compiledField].TargetMember;
}
@@ -2244,7 +2244,7 @@ void Create(EventDef eventDef) {
}
FieldDef? FindField(TypeDef targetType, MemberRef mr) {
- Debug2.Assert(!(importSigComparerOptions is null));
+ Debug2.Assert(importSigComparerOptions is not null);
var comparer = new ImportSigComparer(importSigComparerOptions, SIG_COMPARER_OPTIONS, targetModule);
foreach (var field in targetType.Fields) {
if (!UTF8String.Equals(field.Name, mr.Name))
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporterAssemblyResolver.cs b/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporterAssemblyResolver.cs
index 9863a710d5..b5470f11e3 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporterAssemblyResolver.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ModuleImporterAssemblyResolver.cs
@@ -64,7 +64,7 @@ bool TryResolve(IAssembly assemblyReference, AssemblyNameComparer comparer, [Not
foreach (var reference in references) {
if (comparer.Equals(reference.Assembly, assemblyReference)) {
assembly = GetModule(reference)?.Assembly;
- if (!(assembly is null))
+ if (assembly is not null)
return true;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ModulePatcher.cs b/Extensions/dnSpy.AsmEditor/Compiler/ModulePatcher.cs
index 18da499358..b02236f7a4 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ModulePatcher.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ModulePatcher.cs
@@ -44,7 +44,7 @@ public unsafe bool Patch(ModuleDef module, out RawModuleBytes newModuleData) {
// NOTE: We can't remove the type from the corlib (eg. mscorlib) because the compiler
// (Roslyn) won't recognize it as the corlib if it has any AssemblyRefs.
// A possible fix is to add a new netmodule to the corlib assembly.
- bool fixTypeDefRefs = !(nonNestedEditedType is null) &&
+ bool fixTypeDefRefs = nonNestedEditedType is not null &&
MDPatcherUtils.ExistsInMetadata(nonNestedEditedType) &&
MDPatcherUtils.ReferencesModule(module, nonNestedEditedType?.Module) &&
!module.Assembly.IsCorLib();
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytes.cs b/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytes.cs
index 53e1a68ed3..66c4f63e70 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytes.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytes.cs
@@ -56,7 +56,7 @@ public NativeMemoryRawModuleBytes(int size, bool isFileLayout) {
}
protected override void Dispose(bool disposing) {
- if (!(pointer is null)) {
+ if (pointer is not null) {
NativeMemoryAllocator.Free(pointer, size);
pointer = null;
size = 0;
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytesProvider.cs b/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytesProvider.cs
index a6b843b30b..5a08ba1d85 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytesProvider.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/RawModuleBytesProvider.cs
@@ -41,7 +41,7 @@ sealed unsafe class RawModuleBytesProviderImpl : RawModuleBytesProvider {
// Try the file, if it still exists
var rawData = TryReadFile(module.Location);
- if (!(rawData is null))
+ if (rawData is not null)
return rawData;
// If there's no file, use the in-memory data
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/RemappedTypeTokens.cs b/Extensions/dnSpy.AsmEditor/Compiler/RemappedTypeTokens.cs
index acc8fedc6c..7ac58269ea 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/RemappedTypeTokens.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/RemappedTypeTokens.cs
@@ -68,7 +68,7 @@ public void SetReadOnly() {
public bool TryGetValue(uint token, out uint newToken) {
Debug.Assert(isReadOnly);
var arrayDict = this.arrayDict;
- if (!(arrayDict is null)) {
+ if (arrayDict is not null) {
// Most likely code path
if (token == enclosingTypeToken) {
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/ResourceNodeCreator.cs b/Extensions/dnSpy.AsmEditor/Compiler/ResourceNodeCreator.cs
index 82d46fec01..756f699336 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/ResourceNodeCreator.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/ResourceNodeCreator.cs
@@ -31,7 +31,7 @@ sealed class ResourceNodeCreator {
public ResourceNodeCreator(ResourcesFolderNode rsrcListNode, NodeAndResource[] nodes) {
module = rsrcListNode.GetModule()!;
- Debug2.Assert(!(module is null));
+ Debug2.Assert(module is not null);
this.rsrcListNode = rsrcListNode;
this.nodes = nodes;
}
diff --git a/Extensions/dnSpy.AsmEditor/Compiler/TIAHelper.cs b/Extensions/dnSpy.AsmEditor/Compiler/TIAHelper.cs
index 86b1116603..a0738d4c1d 100644
--- a/Extensions/dnSpy.AsmEditor/Compiler/TIAHelper.cs
+++ b/Extensions/dnSpy.AsmEditor/Compiler/TIAHelper.cs
@@ -71,7 +71,7 @@ static bool stricmp(UTF8String? a, UTF8String? b) {
UTF8String? scope = null, identifier = null;
var tia = td.CustomAttributes.Find("System.Runtime.InteropServices.TypeIdentifierAttribute");
- if (!(tia is null)) {
+ if (tia is not null) {
if (tia.ConstructorArguments.Count >= 2) {
if (tia.ConstructorArguments[0].Type.GetElementType() != ElementType.String)
return null;
@@ -134,9 +134,9 @@ static byte[] Concat(byte[] a, byte b, byte[] c) {
}
static bool CheckEquivalent(TypeDef td) {
- Debug2.Assert(!(td is null));
+ Debug2.Assert(td is not null);
- for (int i = 0; !(td is null) && i < 1000; i++) {
+ for (int i = 0; td is not null && i < 1000; i++) {
if (i != 0) {
var info = GetInfo(td);
if (info is null)
diff --git a/Extensions/dnSpy.AsmEditor/Converters/CilObjectConverter.cs b/Extensions/dnSpy.AsmEditor/Converters/CilObjectConverter.cs
index 7d24493881..599f353815 100644
--- a/Extensions/dnSpy.AsmEditor/Converters/CilObjectConverter.cs
+++ b/Extensions/dnSpy.AsmEditor/Converters/CilObjectConverter.cs
@@ -56,7 +56,7 @@ static class Cache {
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) {
try {
var flags = WriteObjectFlags.None;
- if (!(parameter is null)) {
+ if (parameter is not null) {
foreach (var c in (string)parameter) {
if (c == 's')
flags |= WriteObjectFlags.ShortInstruction;
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CAArgumentVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CAArgumentVM.cs
index e92db83018..1fe093bed8 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CAArgumentVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CAArgumentVM.cs
@@ -154,7 +154,7 @@ void InitializeFrom(CAArgument arg, TypeSig? storageType) {
return value;
}
td = tdr.ResolveTypeDef();
- if (!(td is null) && !td.IsEnum)
+ if (td is not null && !td.IsEnum)
break;
return new EnumInfo() {
EnumType = tdr,
@@ -186,7 +186,7 @@ void InitializeFrom(CAArgument arg, TypeSig? storageType) {
if (tdr.IsSystemType())
return Null.Instance;
td = tdr.ResolveTypeDef();
- if (!(td is null) && !td.IsEnum)
+ if (td is not null && !td.IsEnum)
break;
return EnumInfo.CreateNullArray(tdr);
}
@@ -217,7 +217,7 @@ void InitializeFrom(CAArgument arg, TypeSig? storageType) {
if (tdr.IsSystemType())
return ConvertArray(elemType, oldList);
td = tdr.ResolveTypeDef();
- if (!(td is null) && !td.IsEnum)
+ if (td is not null && !td.IsEnum)
break;
return ConvertEnum(elemType, oldList);
}
@@ -232,10 +232,10 @@ void InitializeFrom(CAArgument arg, TypeSig? storageType) {
object ConvertEnum(TypeSig elemType, IList oldList) {
var td = elemType.GetScopeTypeDefOrRef().ResolveTypeDef();
ElementType underlyingElemType = ElementType.End;
- if (!(td is null) && td.IsEnum)
+ if (td is not null && td.IsEnum)
underlyingElemType = td.GetEnumUnderlyingType().RemovePinnedAndModifiers().GetElementType();
if (!(ElementType.Boolean <= underlyingElemType && underlyingElemType <= ElementType.R8)) {
- if (oldList.Count > 0 && !(oldList[0].Value is null))
+ if (oldList.Count > 0 && oldList[0].Value is not null)
underlyingElemType = ModelUtils.GetElementType(oldList[0].Value.GetType());
}
@@ -337,7 +337,7 @@ CAArgument CreateCAArgument(TypeSig ownerType, object? value) {
return new CAArgument(enumSig, enumInfo.Value);
var res = CreateArray(enumSig, enumInfo.Value);
var list = (IList?)res.Value;
- if (!(list is null)) {
+ if (list is not null) {
for (int i = 0; i < list.Count; i++)
list[i] = new CAArgument(enumSig, list[i].Value);
}
@@ -383,7 +383,7 @@ CAArgument CreateCAArgument(TypeSig ownerType, object? value) {
CAArgument CreateArray(TypeSig elemType, object? value) {
var aryType = new SZArraySig(elemType);
var list = value as System.Collections.IList;
- Debug2.Assert(!(list is null) || value is null);
+ Debug2.Assert(list is not null || value is null);
if (list is null)
return new CAArgument(aryType, null);
var ary = new List(list.Count);
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CANamedArgumentVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CANamedArgumentVM.cs
index a9fb4ed7ac..c8c5a310cb 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CANamedArgumentVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CANamedArgumentVM.cs
@@ -166,7 +166,7 @@ void OnConstantTypeChanged() {
}
void UpdateArgumentType() {
- if (!(CAArgumentVM is null)) {
+ if (CAArgumentVM is not null) {
var ct = (ConstantType)ConstantTypeEnumList.SelectedItem!;
if (ct != ConstantType.Object && ct != ConstantType.ObjectArray)
CAArgumentVM.ConstantTypeVM.ConstantTypeEnumList.SelectedItem = ct;
@@ -181,7 +181,7 @@ void OnNamedArgTypeChanged() {
}
void InitializeFrom(CANamedArgument namedArg, TypeSigCreatorOptions options) {
- if (!(CAArgumentVM is null))
+ if (CAArgumentVM is not null)
CAArgumentVM.PropertyChanged -= caArgumentVM_PropertyChanged;
CAArgumentVM = new CAArgumentVM(ownerModule, namedArg.Argument, options, null);
OnPropertyChanged(nameof(CAArgumentVM));
@@ -314,7 +314,7 @@ void PickEnumType() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var type = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_EnumType, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.EnumTypeDef), EnumType, ownerModule);
- if (!(type is null))
+ if (type is not null)
EnumType = type;
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ConstantTypeVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ConstantTypeVM.cs
index 67f272a545..67c94ffe97 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ConstantTypeVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ConstantTypeVM.cs
@@ -254,7 +254,7 @@ public object? Value {
if (ArraysCanBeNull && enumInfo.Value is null) EnumArrayIsNull = true;
}
else {
- Debug2.Assert(!(enumInfo.Value is null) && !(enumInfo.Value is System.Collections.IList));
+ Debug2.Assert(enumInfo.Value is not null && !(enumInfo.Value is System.Collections.IList));
SetSelectedItem(ConstantType.Enum);
Enum.Value = enumInfo;
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/Converters/BooleanToGridrowLengthConverter.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/Converters/BooleanToGridrowLengthConverter.cs
index 8010d8b70a..a8c6d68549 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/Converters/BooleanToGridrowLengthConverter.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/Converters/BooleanToGridrowLengthConverter.cs
@@ -31,7 +31,7 @@ namespace dnSpy.AsmEditor.DnlibDialogs.Converters {
sealed class BooleanToGridrowLengthConverter : IValueConverter {
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) {
double starValue = 1;
- if (!(parameter is null))
+ if (parameter is not null)
starValue = System.Convert.ToDouble(parameter, culture);
return (bool)value ? new GridLength(starValue, GridUnitType.Star) : new GridLength(0);
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CreateTypeSigArrayVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CreateTypeSigArrayVM.cs
index 6a08f95c22..2621ea98d3 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CreateTypeSigArrayVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CreateTypeSigArrayVM.cs
@@ -77,7 +77,7 @@ public int? RequiredCount {
}
int? requiredCount;
- public bool IsFiniteCount => !(RequiredCount is null);
+ public bool IsFiniteCount => RequiredCount is not null;
public bool IsUnlimitedCount => RequiredCount is null;
public int NumberOfTypesLeft => RequiredCount is null ? -1 : RequiredCount.Value - TypeSigCollection.Count;
public bool CanNotAddMore => !CanAddMore;
@@ -114,7 +114,7 @@ void AddCurrent() {
if (!AddCurrentCanExecute())
return;
var typeSig = TypeSigCreator.TypeSig;
- Debug2.Assert(!(typeSig is null));
+ Debug2.Assert(typeSig is not null);
TypeSigCollection.Add(typeSig);
TypeSigCollection.SelectedIndex = TypeSigCollection.Count - 1;
TypeSigCreator.TypeSig = null;
@@ -123,7 +123,7 @@ void AddCurrent() {
bool AddCurrentCanExecute() =>
IsEnabled &&
(IsUnlimitedCount || NumberOfTypesLeft > 0) &&
- !(TypeSigCreator.TypeSig is null);
+ TypeSigCreator.TypeSig is not null;
public override bool HasError => !IsUnlimitedCount && NumberOfTypesLeft > 0;
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeOptions.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeOptions.cs
index e4b30303c9..995599f651 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeOptions.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeOptions.cs
@@ -39,7 +39,7 @@ public CustomAttributeOptions(CustomAttribute ca) {
}
public CustomAttribute Create() {
- if (!(RawData is null))
+ if (RawData is not null)
return new CustomAttribute(Constructor, RawData);
return new CustomAttribute(Constructor, ConstructorArguments, NamedArguments);
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeVM.cs
index e84a22302a..642c3ce7f9 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/CustomAttributeVM.cs
@@ -50,7 +50,7 @@ public string TypeFullName {
if (Constructor is MethodDef mdCtor) {
var declType = mdCtor.DeclaringType;
- if (!(declType is null))
+ if (declType is not null)
return declType.FullName;
}
@@ -152,11 +152,11 @@ void Args_CollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
}
void Hook(NotifyCollectionChangedEventArgs e) {
- if (!(e.OldItems is null)) {
+ if (e.OldItems is not null) {
foreach (INotifyPropertyChanged? i in e.OldItems)
i!.PropertyChanged -= arg_PropertyChanged;
}
- if (!(e.NewItems is null)) {
+ if (e.NewItems is not null) {
foreach (INotifyPropertyChanged? i in e.NewItems)
i!.PropertyChanged += arg_PropertyChanged;
}
@@ -183,7 +183,7 @@ void PickConstructor() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var newCtor = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Constructor, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.InstanceConstructor), Constructor, ownerModule);
- if (!(newCtor is null))
+ if (newCtor is not null)
Constructor = newCtor;
}
@@ -191,14 +191,14 @@ void PickConstructor() {
public CustomAttributeOptions CreateCustomAttributeOptions() => CopyTo(new CustomAttributeOptions());
void InitializeFrom(CustomAttributeOptions options) {
- IsRawData = !(options.RawData is null);
+ IsRawData = options.RawData is not null;
RawData.Value = options.RawData!;
Constructor = options.Constructor;
ConstructorArguments.Clear();
var sig = Constructor is null ? null : Constructor.MethodSig;
for (int i = 0; i < options.ConstructorArguments.Count; i++) {
TypeSig? type = null;
- if (!(sig is null) && i < sig.Params.Count)
+ if (sig is not null && i < sig.Params.Count)
type = sig.Params[i];
ConstructorArguments.Add(new CAArgumentVM(ownerModule, options.ConstructorArguments[i], new TypeSigCreatorOptions(ownerModule, decompilerService), type));
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/EnumDataFieldVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/EnumDataFieldVM.cs
index 4f60777304..d2498ec6f3 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/EnumDataFieldVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/EnumDataFieldVM.cs
@@ -40,9 +40,9 @@ struct EnumInfo {
public override string ToString() {
var td = EnumType.ResolveTypeDef();
- if (!(td is null)) {
+ if (td is not null) {
var s = ModelUtils.GetEnumFieldName(td, Value);
- if (!(s is null))
+ if (s is not null)
return $"{EnumType}.{s}";
}
if (!IsArray)
@@ -86,7 +86,7 @@ public ITypeDefOrRef? EnumType {
enumUnderlyingTypeField = null;
else {
enumUnderlyingTypeField = CreateEnumUnderlyingTypeField(td.GetEnumUnderlyingType().RemovePinnedAndModifiers().GetElementType());
- if (!(enumUnderlyingTypeField is null)) {
+ if (enumUnderlyingTypeField is not null) {
enumUnderlyingTypeField.StringValue = StringValue;
ForceWriteStringValue(enumUnderlyingTypeField.StringValue);
}
@@ -114,7 +114,7 @@ protected EnumDataFieldVMBase(ModuleDef ownerModule, EnumInfo value, Action 0)
+ if (ownerMethod is not null && ownerMethod.GenericParameters.Count > 0)
typeSigCreatorOptions.CanAddGenericMethodVar = true;
TypeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ImplMapVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ImplMapVM.cs
index 1177c376d8..9ce7de377a 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ImplMapVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ImplMapVM.cs
@@ -144,7 +144,7 @@ public ImplMap? ImplMap {
return ownerModule.UpdateRowId(new ImplMapUser(modRef, Name, Attributes));
}
set {
- IsEnabled = !(value is null);
+ IsEnabled = value is not null;
if (value is null)
return;
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ListVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ListVM.cs
index baa3e60c9b..f5198dd4b7 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ListVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ListVM.cs
@@ -112,7 +112,7 @@ public override void EditItem() {
return;
int index = Collection.SelectedIndex;
var vm = EditClone(Clone(Collection[index]));
- if (!(vm is null)) {
+ if (vm is not null) {
Collection[index] = vm;
Collection.SelectedIndex = index;
}
@@ -125,7 +125,7 @@ protected virtual void AddItem() {
return;
var vm = AddNew(Create());
- if (!(vm is null)) {
+ if (vm is not null) {
var index = GetAddIndex(vm);
Collection.Insert(index, vm);
Collection.SelectedIndex = index;
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MarshalTypeVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MarshalTypeVM.cs
index 7a021f3baf..1e318eb8cd 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MarshalTypeVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MarshalTypeVM.cs
@@ -347,9 +347,9 @@ static TypeSigCreatorVM CreateTypeSigCreatorVM(ModuleDef ownerModule, IDecompile
OwnerMethod = ownerMethod,
NullTypeSigAllowed = allowNullTypeSig,
};
- if (!(ownerType is null) && ownerType.GenericParameters.Count == 0)
+ if (ownerType is not null && ownerType.GenericParameters.Count == 0)
typeSigCreatorOptions.CanAddGenericTypeVar = false;
- if (!(ownerMethod is null) && ownerMethod.GenericParameters.Count > 0)
+ if (ownerMethod is not null && ownerMethod.GenericParameters.Count > 0)
typeSigCreatorOptions.CanAddGenericMethodVar = true;
var typeSigCreator = new TypeSigCreatorVM(typeSigCreatorOptions);
typeSigCreator.PropertyChanged += handler;
@@ -465,7 +465,7 @@ public MarshalType? Type {
throw new InvalidOperationException();
}
set {
- IsEnabled = !(value is null);
+ IsEnabled = value is not null;
if (value is null)
return;
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberPickerVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberPickerVM.cs
index ba26cf949e..033ec51b72 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberPickerVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberPickerVM.cs
@@ -64,7 +64,7 @@ public object? SelectedItem {
if (selectedItem != value) {
selectedItem = value;
OnPropertyChanged(nameof(SelectedItem));
- if (!(value is null)) {
+ if (value is not null) {
searchResult = null;
OnPropertyChanged(nameof(SearchResult));
}
@@ -77,7 +77,7 @@ public object? SelectedItem {
public object? SelectedDnlibObject {
get {
var res = SearchResult;
- if (!(res is null)) {
+ if (res is not null) {
var obj = res.Object;
if (obj is AssemblyDef && filter.GetResult((AssemblyDef)obj).IsMatch)
@@ -105,7 +105,7 @@ public object? SelectedDnlibObject {
}
var item = documentTreeView.TreeView.FromImplNode(SelectedItem);
- if (!(item is null)) {
+ if (item is not null) {
if (item is AssemblyDocumentNode && filter.GetResult(((AssemblyDocumentNode)item).Document.AssemblyDef!).IsMatch)
return ((AssemblyDocumentNode)item).Document;
else if (item is ModuleDocumentNode && filter.GetResult(((ModuleDocumentNode)item).Document.ModuleDef!).IsMatch)
@@ -185,7 +185,7 @@ public ISearchResult? SearchResult {
if (searchResult != value) {
searchResult = value;
OnPropertyChanged(nameof(SearchResult));
- if (!(value is null)) {
+ if (value is not null) {
selectedItem = null;
OnPropertyChanged(nameof(SelectedItem));
}
@@ -332,7 +332,7 @@ public void Clear() {
void CancelSearch() {
TooManyResults = false;
delayedSearch.Cancel();
- if (!(fileSearcher is null)) {
+ if (fileSearcher is not null) {
fileSearcher.Cancel();
fileSearcher = null;
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberRefVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberRefVM.cs
index 241f593b9f..823fe4d854 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberRefVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MemberRefVM.cs
@@ -116,7 +116,7 @@ void InitializeFromField() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var newField = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Field, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.FieldDef), null, typeSigCreatorOptions.OwnerModule);
- if (!(newField is null))
+ if (newField is not null)
InitializeFrom(new MemberRefOptions(typeSigCreatorOptions.OwnerModule.Import(newField)));
}
@@ -124,7 +124,7 @@ void InitializeFromMethod() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var newMethod = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Method, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.MethodDef), null, typeSigCreatorOptions.OwnerModule);
- if (!(newMethod is null)) {
+ if (newMethod is not null) {
if (typeSigCreatorOptions.OwnerModule.Import(newMethod) is MemberRef mr)
InitializeFrom(new MemberRefOptions(mr));
}
@@ -134,7 +134,7 @@ void PickType() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var newType = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Type, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.TypeDef), Class as ITypeDefOrRef, typeSigCreatorOptions.OwnerModule);
- if (!(newType is null))
+ if (newType is not null)
Class = newType;
}
@@ -150,10 +150,10 @@ void PickMethodDef() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var newMethod = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Method, new SameAssemblyDocumentTreeNodeFilter(typeSigCreatorOptions.OwnerModule, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.MethodDef)), Class as IMethod, typeSigCreatorOptions.OwnerModule);
- if (!(newMethod is null)) {
+ if (newMethod is not null) {
var md = newMethod as MethodDef;
- Debug2.Assert(!(md is null));
- if (!(md is null))
+ Debug2.Assert(md is not null);
+ if (md is not null)
Class = md;
}
}
@@ -162,9 +162,9 @@ void PickModuleRef() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var document = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Module, new SameAssemblyDocumentTreeNodeFilter(typeSigCreatorOptions.OwnerModule, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.ModuleDef)), null, typeSigCreatorOptions.OwnerModule);
- if (!(document is null)) {
+ if (document is not null) {
var module = document.ModuleDef;
- if (!(module is null)) {
+ if (module is not null) {
var modRef = new ModuleRefUser(typeSigCreatorOptions.OwnerModule, module.Name);
Class = typeSigCreatorOptions.OwnerModule.UpdateRowId(modRef);
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodDefVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodDefVM.cs
index ea253f404a..f805df5ba3 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodDefVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodDefVM.cs
@@ -62,6 +62,6 @@ public MethodDefVM(MethodDef? method) {
return string.Empty;
}
- public override bool HasError => !(Method is null);
+ public override bool HasError => Method is not null;
}
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSigCreatorVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSigCreatorVM.cs
index 9530eb6375..6bc6d00499 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSigCreatorVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSigCreatorVM.cs
@@ -156,7 +156,7 @@ public MethodSigCreatorVM(MethodSigCreatorOptions options) {
GenericParameterCount = new UInt32VM(0, a => {
HasErrorUpdated();
OnPropertyChanged(nameof(SignatureFullName));
- if (!(GenericParameterCount is null) && !GenericParameterCount.HasError)
+ if (GenericParameterCount is not null && !GenericParameterCount.HasError)
IsGeneric = GenericParameterCount.Value != 0;
}) {
Min = ModelUtils.COMPRESSED_UINT32_MIN,
@@ -204,7 +204,7 @@ void WriteSignature(MethodBaseSig? sig) {
ParametersCreateTypeSigArray.TypeSigCollection.AddRange(sig.Params);
GenericParameterCount.Value = sig.GenParamCount;
SentinelCreateTypeSigArray.TypeSigCollection.Clear();
- if (!(sig.ParamsAfterSentinel is null))
+ if (sig.ParamsAfterSentinel is not null)
SentinelCreateTypeSigArray.TypeSigCollection.AddRange(sig.ParamsAfterSentinel);
}
}
@@ -214,13 +214,13 @@ void AddReturnType() {
throw new InvalidOperationException();
var newTypeSig = typeSigCreator.Create(options.TypeSigCreatorOptions.Clone(dnSpy_AsmEditor_Resources.CreateReturnType), ReturnType, out bool canceled);
- if (!(newTypeSig is null))
+ if (newTypeSig is not null)
ReturnType = newTypeSig;
}
protected override string? Verify(string columnName) {
if (columnName == nameof(ReturnType))
- return !(ReturnType is null) ? string.Empty : dnSpy_AsmEditor_Resources.ReturnTypeRequired;
+ return ReturnType is not null ? string.Empty : dnSpy_AsmEditor_Resources.ReturnTypeRequired;
return string.Empty;
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSpecVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSpecVM.cs
index 0f6cd23717..04ec78dd5e 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSpecVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/MethodSpecVM.cs
@@ -83,7 +83,7 @@ void PickMethod() {
if (dnlibTypePicker is null)
throw new InvalidOperationException();
var newMethod = dnlibTypePicker.GetDnlibType(dnSpy_AsmEditor_Resources.Pick_Method, new FlagsDocumentTreeNodeFilter(VisibleMembersFlags.MethodDef), Method, typeSigCreatorOptions.OwnerModule);
- if (!(newMethod is null))
+ if (newMethod is not null)
Method = newMethod;
}
@@ -94,7 +94,7 @@ void InitializeFrom(MethodSpecOptions options) {
Method = options.Method;
var gim = options.Instantiation as GenericInstMethodSig;
CreateTypeSigArrayVM.TypeSigCollection.Clear();
- if (!(gim is null))
+ if (gim is not null)
CreateTypeSigArrayVM.TypeSigCollection.AddRange(gim.GenericArguments);
CustomAttributesVM.InitializeFrom(options.CustomAttributes);
}
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ModelUtils.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ModelUtils.cs
index 033848ece3..d1237431c4 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ModelUtils.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ModelUtils.cs
@@ -29,7 +29,7 @@ static class ModelUtils {
public const int COMPRESSED_INT32_MAX = 0x0FFFFFFF;
public static bool IsSystemType(this ITypeDefOrRef? tdr) =>
- !(tdr is null) &&
+ tdr is not null &&
tdr.DeclaringType is null &&
tdr.Namespace == "System" &&
tdr.Name == "Type" &&
@@ -59,7 +59,7 @@ public static ElementType GetElementType(Type? type) {
if (td is null || value is null)
return null;
foreach (var fd in td.Fields) {
- if (fd.IsLiteral && !(fd.Constant is null) && value.Equals(fd.Constant.Value))
+ if (fd.IsLiteral && fd.Constant is not null && value.Equals(fd.Constant.Value))
return fd.Name;
}
return null;
diff --git a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ObjectListDataFieldVM.cs b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ObjectListDataFieldVM.cs
index 42c4230678..59a30f5d2f 100644
--- a/Extensions/dnSpy.AsmEditor/DnlibDialogs/ObjectListDataFieldVM.cs
+++ b/Extensions/dnSpy.AsmEditor/DnlibDialogs/ObjectListDataFieldVM.cs
@@ -49,7 +49,7 @@ public ObjectListDataFieldVM(ModuleDef ownerModule, Action onUpdate
public ObjectListDataFieldVM(ModuleDef ownerModule, IList